#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;

ll a, b;

ll comp(ll x, ll y, int n) {
	//x, y, are <= n+1 digits long
	if (n == 0)
		return 1+y-x;
	if ((x >> n) == (y >> n))
		return comp(x%(1LL<<n), y%(1LL<<n), n-1);

	// cout << n << ' ' << x << ' ' << y << endl;
	int s[65];

	for (int i = 0; i < n+1; ++i) {
		s[i] = y%2;
		y/= 2;
	}

	int ind = -1;
	for (int i = n-1; i >= 0; --i) {
		if (s[i] == 1) {
			ind = i;
			break;
		}
	}

	ll t = (1LL<<(ind+1))-1;
	ll ans = 0;
	ans += (1LL<<n)-x;
	if (t < x) {
		ans += t+1+(1LL<<n)-x;
	} else {
		ans += (1LL<<n);
	}

	return ans;
}

int main() {
	cin >> a >> b;
	cout << comp(a, b, 61) << endl;
}