//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
ll a,b,res;
int main(){
	scanf("%lld%lld",&a,&b);
	if(a==b)return puts("1"),0;
	R int r,k;
	for(r=59;(a>>r&1)==(b>>r&1);--r);
	a&=(1ll<<(r+1))-1,b&=(1ll<<(r+1))-1;
	res=(1ll<<(r+1))-a;
	for(k=r-1;(~k)&&(b>>k&1^1);--k);
	if(a>(1ll<<(k+1)))res-=a-(1ll<<(k+1));
	printf("%lld\n",res);
	return 0;
}