#include <bits/stdc++.h>
using namespace std;

long long a, b;
int main() {
	cin >> a >> b;
	if(a == b) cout << 1, exit(0);
	int r = 60;
	while((a >> r & 1) == (b >> r & 1)) --r;
	a &= (1ll << r+1)-1, b &= (1ll << r+1)-1;
	int k = r-1;
	while(k >= 0 && !(b >> k & 1)) --k;
	long long ans = (1ll << r+1) - a;
	if(1ll << k+1 < a) ans -= a - (1ll << k+1);
	cout << ans;
}
