#include <cstdio> 
#define llg long long 
using namespace std; 

llg A, B, T, ans = 0, K, L; 
int t, k = 0; 

int main() {
	scanf("%lld%lld", &A, &B); 
	if (A == B) return puts("1"), 0; 
	for (int i = 61; i >= 0; --i) {
		T = 1ll << i; t = i; 
		if ((A & T) != (B & T)) break; 
		if ((A & T)) A ^= T, B ^= T; 
	} 
	for (int i = t - 1; i >= 0; --i) 
		if (B & (1ll << i)) 
			{k = i; K = (1ll << (k + 1)) - 1; break; } 
	ans += T - A; 
	if (K >= A) ans += T; 
	else ans += K + T - A + 1; 
	printf("%lld\n", ans); 
	return 0; 
} 