#include <cstdio>

typedef long long ll;
int main()
{
	ll a, b; scanf("%lld%lld", &a, &b);
	if (a == b) return !printf("1\n");
	ll c = a ^ b;
	int r = 63 - __builtin_clzll(c);
	ll T = 1ll << r, A = a & (T - 1), B = b & (T * 2 - 1);
	int k = 63 - __builtin_clzll(B ^ (1ll << r));
	if (B == 1ll << r) k = -1;
//	printf("%d %d\n", r, k);
	
//	printf("%lld %lld %lld\n", A, B, T);
	ll ans = 0;
	ans += T - A;
	ll la = T, ra = T + (1ll << (k + 1)) - 1;
	ll lb = T + A, rb = 2 * T - 1;
	if (lb <= ra) ans -= ra - lb + 1;
	ans += ra - la + 1;
	ans += rb - lb + 1;
	
//	printf("%lld %lld\n%lld %lld\n", la, ra, lb, rb);
	printf("%lld\n", ans);
	return 0;
}