#include <cstdio>

typedef long long LL;

LL A, B;

LL Solve(LL l, LL r, LL a, LL b) {
	if (l == a && b == r - 1) return r - l;
	LL mid = (l + r) >> 1;
	if (a <= b) {
		if (b < mid) return Solve(l, mid, a, b);
		if (mid <= a) return Solve(mid, r, a, b);
		LL ans = Solve(l, mid, a, mid - 1);
		if (a - l + mid - b >= 2) ans += Solve(mid, r, a - l + mid, b);
		else ans += r - mid;
		return ans;
	} else {
		if (b >= mid) return r - l;
		if (a < mid) return Solve(l, mid, a, b) + r - mid;
		return Solve(l, mid, l, b) + r - a;
	}
}

int main() {
	scanf("%lld%lld", &A, &B);
	printf("%lld\n", Solve(0, 1ll << 60, A, B));
	return 0;
}