http://acm.fzu.edu.cn/problem.php?pid=1563
Input
Output
Sample input
2 2 7 3 1000000
Sample output
4 78497