A≤x≤B, C≤y≤D인 정수 쌍 (x, y) 중 x/y를 기약분수 a/b로 줄였을 때 a+b≤999가 되는 쌍의 개수를 센다. u,gcd를 해)
어려움8정수론수학아직 제출이 없습니다시간 제한1초메모리 제한1024 MBAbout 44 days are left before College Scholastic Ability Test is held. This exam aims to measure students' achievement of National Curriculum standards and scholastic ability required for college education. (http://www.kice.re.kr/sub/info.do?m=0205&s=english)
One of the subjects covered by this test is Mathematics, which consists of 21 multiple choice questions and 9 short-answer questions. The answer of each short-answer question is guaranteed to be a unique positive integer below 1000, as you can see from the answer sheet below.

However, the organizers might want to give students short-answer questions with non-integer answers, such as 23 or 35. Usually, the workaround is to write the answer in a canonical form, and then sum up all the integers inside that form and ask students to write that number instead.
In particular, when the answer is a positive rational number ba, the organizers usually ask students to reduce it and sum up the numerator and the denominator of the reduced fraction. For example, when the answer is 1018, the student should reduce it to 59 and write the final answer as 9+5=14.

However, when the answer is 500521, the reduced fraction is also 500521, so the student should write the final answer as 521+500=1021. But this shouldn't happen, since all the answers for the short-answer questions are below 1000. To avoid this situation, the organizers should make sure that after reducing the fraction, the sum of the numerator and the denominator shouldn't exceed 999. Let's call such fractions as Suneung Fractions. For example, 21996 and 1018 are Suneung fractions, while 21998 and 500521 are not.
Suppose that, this year, one of the organizers wrote a problem, and the answer to that problem is yx. Since the problem is not finalized yet, the only thing we know is A≤x≤B and C≤y≤D holds, for given A,B,C,D. The organizers want to know, among all the pairs (x,y), how many of yx is a Suneung fraction. Write a program that counts this number.
The first and only line contains four space-separated integers A,B,C and D (1≤A≤B≤1012, 1≤C≤D≤1012)
Print the number of integral pairs (x, y) (A≤x≤B, C≤y≤D), where yx is a Suneung fraction.