#include<stdio.h>
#include<string.h>
int a[100];
int dp[100][100][100];
int dfs(int pos,int cot0,int cot1,int lead,bool limit){
if(pos==-1){
if(cot0>=cot1) return 1;
if(lead==0) return 1;
return 0;
}
if(!limit && lead==1 && dp[pos][cot0][cot1]!=-1)
return dp[pos][cot0][cot1];
int ans=0;
int up = limit ? a[pos] : 1;
for(int i=0;i<=up;i++){
if(lead==0){
if(i==0)
ans+=dfs(pos-1,0,0,0,limit&&i==up);
else
ans+=dfs(pos-1,cot0,cot1+1,1,limit&&i==up);
}
else{
if(i==1)
ans+=dfs(pos-1,cot0,cot1+1,1,limit&&i==up);
else
ans+=dfs(pos-1,cot0+1,cot1,1,limit&&i==up);
}
}
if(!limit && lead == 1)
dp[pos][cot0][cot1]=ans;
return ans;
}
int solve(int x){
int pos=0;
while(x){
a[pos]=x%2;
x/=2;
pos++;
}
return dfs(pos-1,0,0,0,true);
}
int main(){
int l,r;
while(~scanf("%d%d",&l,&r)){
memset(dp,-1,sizeof(dp));
printf("%d\n",solve(r)-solve(l-1));
}
return 0;
}
#include<string.h>
int a[100];
int dp[100][100][100];
int dfs(int pos,int cot0,int cot1,int lead,bool limit){
if(pos==-1){
if(cot0>=cot1) return 1;
if(lead==0) return 1;
return 0;
}
if(!limit && lead==1 && dp[pos][cot0][cot1]!=-1)
return dp[pos][cot0][cot1];
int ans=0;
int up = limit ? a[pos] : 1;
for(int i=0;i<=up;i++){
if(lead==0){
if(i==0)
ans+=dfs(pos-1,0,0,0,limit&&i==up);
else
ans+=dfs(pos-1,cot0,cot1+1,1,limit&&i==up);
}
else{
if(i==1)
ans+=dfs(pos-1,cot0,cot1+1,1,limit&&i==up);
else
ans+=dfs(pos-1,cot0+1,cot1,1,limit&&i==up);
}
}
if(!limit && lead == 1)
dp[pos][cot0][cot1]=ans;
return ans;
}
int solve(int x){
int pos=0;
while(x){
a[pos]=x%2;
x/=2;
pos++;
}
return dfs(pos-1,0,0,0,true);
}
int main(){
int l,r;
while(~scanf("%d%d",&l,&r)){
memset(dp,-1,sizeof(dp));
printf("%d\n",solve(r)-solve(l-1));
}
return 0;
}