#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define maxn 1e9
//int a[maxn];
int main()
{
int m,n;
while(~scanf("%d%d",&m,&n)&&(m!=0&&n!=0))
{
int ans=1;
int num=1;
//m=2*m+1;
int R,L;
L=2*m;
R=2*m+1;
while(R<=n)
{
ans*=2;
num+=ans;
L=2*L;
R=2*R+1;
// printf("ans1=%d\n",ans);
}
//m=(m-1)/2;
//printf("m=%d\n",m);
if(L<=n)//这个条件一开始没有找到,所以卡了很久
{
num+=(n-L)+1;
}
//ans+=1;
printf("%d\n",num);
}
return 0;
}