cho.sh
Notes
Loading...

Nice Numbers

Time limit

2s

Memory limit

128 MB

Problem

A nonnegative integer is called a nice number if, in its binary representation, the same digit 0 or 1 appears at least three times consecutively. For example, 8 is 1000 in binary and 15 is 1111 in binary, so both are nice numbers. On the other hand, 27 is 11011 in binary, so it is not a nice number.

Given two integers L and R, determine how many nice numbers are between L and R, inclusive.

Input

The first line contains two integers L and R.

0 <= L <= R <= 2147483647

Output

Print the number of nice numbers between L and R, inclusive.