#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 62
int main(){
    ll a,b;cin>>a>>b;
    if(a==b){
	cout<<1<<endl;
	return 0;
    }
    ll i;
    for(i=(1LL<<N);i;i>>=1){
	if((a&i)!=(b&i))break;
	if(a&i)a-=i;
	if(b&i)b-=i;
    }
    ll j;
    for(j=i>>1;j;j>>=1){
	if(b&j)break;
    }
    if(j==0)j++;
    else j<<=1;
    ll ans=i-a;
    if(j<=a)ans=ans*2+j;
    else ans+=i;
    cout<<ans<<endl;
    return 0;
}
