No tag edit access

D. Two Arithmetic Progressions

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou are given two arithmetic progressions: *a*_{1}*k* + *b*_{1} and *a*_{2}*l* + *b*_{2}. Find the number of integers *x* such that *L* ≤ *x* ≤ *R* and *x* = *a*_{1}*k*' + *b*_{1} = *a*_{2}*l*' + *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

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Mar/20/2019 11:26:32 (f2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|