Олимпиадный тренинг

Задача 38300. Buses


Berland has a deplorable situation with intercity bus service. There are only three bus routes in the whole country, each of which runs only one bus. On the first day of the new year, at exactly midnight, all three buses depart on their routes from the capital of Berland. It is known that the first bus needs a minutes to cover the whole route and return to the capital, the second — b minutes, and the third — c minutes. Thus, the first bus departs from the capital of Berland at times 0, a, 2a, 3a, the second — at times 0, b, 2b, 3b , and the third at times 0, c, 2c, 3c .

The moment of time is called suitable for transfer if at this moment all three buses depart from the capital of Berland. For example, if a=1, b=2, c=1, then times 0 and 2 are eligible for transfers, but time 1 is not, because at that time a second bus is on the way. Berland — a special country with a special measurement of time, so there are exactly t minutes in a Berland day. This means that on the first day all moments of time from 0 to (t & minus; 1) inclusive occur, on the second day — from the t-th to (2t−1)-th inclusive, to the third — from 2t to (3t−1) inclusive and so on.

The Ministry of Transport of Berland was interested in how many suitable time points for a transfer will occur on the d-th day in Berland. Unfortunately, local officials are busy with other matters, so you have been assigned to answer this question.

Input
Five lines contain five integers a, b, c, t  and d (1≤a, b, c≤106 , 1≤t, d≤109 ) — the time of the complete passage of the route by the first, second and third buses, respectively, the number of minutes in a day and the number of the day, which is of interest to the Ministry of Transport of Berland.

Imprint
Print a single integer — the number of times suitable for transplantation on the d-th day.
Examples
# Input Output Explanations
1 1
2
1
3
1
2 A day lasts 3 minutes, so all times on a day with number 1 — it 0, 1, 2, of which 0 and 2 times are eligible for transplant
2 2
3
4
7
2
1 Here we consider the second day with time points 7, 8, 9, 10, 11, 12, 13. The first bus leaves at times 8, 10, 12, the second bus — at times 9 and 12, and the third — at times 8 and 12. Thus, only time 12 is suitable for transplantation.
3 2
3
4
3
3
0 There is no suitable time to transplant