4595: Two Arithmetic Progressions

内存限制:256 MB 时间限制:2 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
You are given two arithmetic progressions: a1k+b1 and a2l+b2. Find the number of integers x such that LxR and x=a1k'+b1=a2l'+b2, for some integers k',l'≥0.
Input
The only line contains six integers a1,b1,a2,b2,L,R (0<a1,a2≤2·109,-2·109b1,b2,L,R≤2·109,LR).
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

输入样例 复制


输出样例 复制