apps_33
Submit solution
Points:
3
Time limit:
30.0s
Memory limit:
250M
Problem type
Allowed languages
Python
You are given two arithmetic progressions: a_1k + b_1 and a_2l + b_2. Find the number of integers x such that L ≤ x ≤ R and x = a_1k' + b_1 = a_2l' + b_2, for some integers k', l' ≥ 0.
-----Input-----
The only line contains six integers a_1, b_1, a_2, b_2, L, R (0 < a_1, a_2 ≤ 2·10^9, - 2·10^9 ≤ b_1, b_2, L, R ≤ 2·10^9, L ≤ R).
-----Output-----
Print the desired number of integers x.
-----Examples-----
Input 2 0 3 3 5 21
Output 3
Input 2 4 3 0 6 17
Output 2
Comments