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
The only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 1018) — the first year and the last year in Limak's interval respectively.
Output
Print one integer – the number of years Limak will count in his chosen interval.
Examples
Input
5 10
Output
2
Input
2015 2015
Output
1
Input
100 105
Output
0
Input
72057594000000000 72057595000000000
Output
26
Note
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.
思路:仔细观察会发现这样的规律:
100-1=11
11-1=10
。。。。
1000-1=111
111-1=110
111-10=101
。。。。。
10000-1=1111
1111-1=1110
1111-10=1101
1111-100=1011
可以发现只有一个零的二进制数=(1<<i)-1-(1<<j),这样的话我们穷举即可
#include<cstdio>
#include<iostream>
#include<string.h>
#define sc(a) scanf("%d",&a)
#define scl(a) scanf("%lld",&a)
#define mem(a) memset(a,0,sizeof(a));
#define pr(a) printf("%d\n",a);
#define prl(a) printf("%lld\n",a);
typedef long long int ff;
using namespace std;
int main()
{
ff a, b;
scl(a), scl(b);
int ans = 0;
ff num;
bool flag = false;
for (ff i = 2;; i++) {
for (ff j = 0; j <= i - 2; j++) {
num = (1LL << i) - 1 - (1LL << j);//1LL是代表存储空间为8个字节的常量
if (num >= a && num <= b)
ans++;
if (num > b)
flag = true;
}
if (flag)
break;
}
cout << ans;
return 0;
}