#include<bits/stdc++.h>
#define ll long long
using namespace std;
int T,n,p,q,u;
ll l,r,ans,v;

ll read(){
	ll x=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}

void print(ll x){
	if(x>=10) print(x/10);
	putchar(x%10+'0');
}

int main(){
	l=read(),r=read();
	if(l==r){
		puts("1");return 0;
	}
	for(int i=60;i>=0;i--){
		p=(l&(1ll<<i))>0,q=(r&(1ll<<i))>0;
		if(p!=q){u=i;break;}
		if(p) l^=(1ll<<i),r^=(1ll<<i);
	}
	v=-1;
	for(int i=u-1;i>=0;i--){
		p=(r&(1ll<<i))>0;
		if(p){v=i;break;}
	}
	v=1ll<<(v+1);
	if(l>v) ans=(1ll<<u)+v-l+(1ll<<u)-l;
	else ans=(1ll<<(u+1))-l;
	print(ans),puts("");

	return 0;
}