# [bzoj 1662--Usaco2006 Nov]Round Numbers 圆环数

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int a[35],b[35],mi[35];
long long f[35][35][35];
long long dfs(int pos,int n0,int n1,bool lead,bool limt)
{
if(pos==0)
{
if(n0>=n1)return 1;
return 0;
}
if(lead==false && limt==false && f[pos][n0][n1]!=-1)return f[pos][n0][n1];
int up=1,ans=0;
if(limt==true)up=a[pos];
for(int i=0;i<=up;i++)
{
int he1=n0,he2=n1;bool bk1=false,bk2=false;
if(i==1)he2++;
if(limt==true && i==a[pos])bk2=true;
ans+=dfs(pos-1,he1,he2,bk1,bk2);
}
return ans;
}
long long solve(int x)
{
int pos=0,ss=30;
bool bk=true;
while(x)
{
if(x>=mi[ss])
{
b[++pos]=1;
x-=mi[ss];
bk=false;
}
else
{
if(bk==false)b[++pos]=0;
}
ss--;
}
ss++;
while(ss--)b[++pos]=0;
for(int i=1;i<=pos;i++)a[i]=b[pos-i+1];
return dfs(pos,0,0,true,true);
}
int main()
{
int n,m;
scanf("%d%d",&n,&m);
mi[0]=1;
for(int i=1;i<=30;i++)mi[i]=mi[i-1]*2;
memset(f,-1,sizeof(f));
printf("%lld\n",solve(m)-solve(n-1));
return 0;
}
10-22 258

10-30 394
11-30 485
07-26 93
10-28 62