#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cctype>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
typedef long long LL;
LL a,b;
int x,p=-1;

LL calc(LL a,LL b,LL c,LL d)
{
	if(c<=b) return d-a+1;
	return b-a+1+d-c+1;
}

int main()
{
	scanf("%lld%lld",&a,&b);
	if(a==b) return puts("1"),0;
	rep(i,0,60) if((a^b)&(1ll<<i)) x=i;
	a&=(1ll<<x+1)-1,b&=(1ll<<x+1)-1;
	rep(i,0,60) if((1ll<<i)+(1ll<<x)<=b) p=i;
	printf("%lld\n",calc(a,(1ll<<x)+(1ll<<p+1)-1,a+(1ll<<x),(1ll<<x+1)-1));
	return 0;
}