#include<bits/stdc++.h>
using namespace std;
int a,b,dp[40][110],two[40],to,pow2[40];
int dfs(int len,int mx,int cha){
if(len==0&&cha>=30)return 1;
else return 0;
if(dp[len][cha]!=-1)return dp[len][cha];
int res=0;
if(pow2[len]<=mx)res+=dfs(len-1,mx-pow2[len],cha-1);
res+=dfs(len-1,mx,cha+1);
dp[len][cha]=res;
return res;
}
int s(int x){
int y=x;
to=0;
memset(two,0,sizeof(two));
while(y){
two[++to]=y%2;
y/=2;
}
memset(dp,-1,sizeof(dp));
return dfs(to,x,30);
}
int main(){
cin>>a>>b;
for(int i=1,x=1;i<=35;i++){
pow2[i]=x;
x<<=1;
}
cout<<s(b)-s(a);
return 0;
}