//Nipah!~☆
#include<bits/stdc++.h>
using namespace std;

long long ans;
long long a, b;

void in();
void solve();
long long bp(long long);
void out();

int main(){
	ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	in();
	solve();
	out();
}

void in(){
	cin >> a >> b;
}

void solve(){
	while(a && bp(a) == bp(b)){
		a -= 1ll << bp(a);
		b -= 1ll << bp(b);
	}
	if(b == 0){
		ans = 1;
		return;
	}
	long long pwr = bp(b);
	long long MX = b - (1ll << pwr);
	MX = (1ll << bp(MX) + 1) - 1;
	if(MX >= a)
		ans = (1ll << pwr + 1) - a;
	else
		ans = MX + ((1ll << pwr) - a) * 2 + 1;
}

long long bp(long long x){
	long long ret = -1;
	while(x){
		ret++;
		x >>= 1;
	}
	return ret;
}

void out(){
	cout << ans;
}