#include <bits/stdc++.h>
#define inf 2333333333333333
#define N 1000010
#define p(a) putchar(a)
#define For(i,a,b) for(long long i=a;i<=b;++i)
//by war
//2020.7.15
using namespace std;
long long l,r;
long long f[36][36][3][36][36];
vector<long long>dim;
void in(long long &x){
long long y=1;char c=getchar();x=0;
while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
while(c<='9'&&c>='0'){ x=(x<<1)+(x<<3)+c-'0';c=getchar();}
x*=y;
}
void o(long long x){
if(x<0){p('-');x=-x;}
if(x>9)o(x/10);
p(x%10+'0');
}
long long dfs(long long x,long long st,long long op,long long cnt0,long long cnt1){
if(!x){
if(cnt0>=cnt1) return 1;
else return 0;
}
if(~f[x][st][op][cnt0][cnt1]) return f[x][st][op][cnt0][cnt1];
long long maxx=op?dim[x]:1,r=0;
For(i,0,maxx){
if(st==11 && i==0) r+=dfs(x-1,11,op&(i==maxx),cnt0,cnt1);
else r+=dfs(x-1,i,op&(i==maxx),cnt0+(i==0),cnt1+(i==1));
}
return f[x][st][op][cnt0][cnt1]=r;
}
long long deal(long long x){
memset(f,-1,sizeof f);
dim.clear();
dim.push_back(2333);
while(x){
dim.push_back(x%2);
x/=2;
}
return dfs(dim.size()-1,11,1,0,0);
}
signed main(){
in(l);in(r);
o(deal(r)-deal(l-1));
return 0;
}