2549.New Year and Old Property

Time Limit: 1s Memory Limit: 256MB

The year 2015 is almost over.

Limak is a little polar bear. He has recently learnt about the binary system. He noticed that the passing year has exactly one zero in its representation in the binary system- 201510=111110111112. Note that he doesn't care about the number of zeros in the decimal representation.

Limak chose some interval of years. He is going to count all years from this interval that have exactly one zero in the binary representation. Can you do it faster?

Assume that all positive integers are always written without leading zeros.

Input Format(From the terminal/stdin)

The only line of the input contains two integers a and b (1 \le a \le b \le 1018)- the first year and the last year in Limak's interval respectively.

Output Format(To the terminal/stdout)

Print one integer— the number of years Limak will count in his chosen interval.

Sample Input 1

Copy
5 10
 ·  \n

Sample Output 1

Copy
2
 \n

Sample Input 2

Copy
2015 2015
    ·    \n

Sample Output 2

Copy
1
 \n

Sample Input 3

Copy
100 105
   ·   \n

Sample Output 3

Copy
0
 \n

Sample Input 4

Copy
72057594000000000 72057595000000000
                 ·                 \n

Sample Output 4

Copy
26
  \n

Hints

In the first sample Limak's interval contains numbers 510=1012, 610=1102, 710=1112, 810=10002, 910=10012 and 1010=10102. Two of them (1012 and 1102) have the described property.

Submit

请先 登录

© 2025 FAQs