#include<cstdio>
typedef long long ll;
ll A, B, ans;
int main(){
	scanf("%lld%lld", &A, &B);
	if(A == B) return puts("1"), 0;
	int r = 60;
	for(; (A >> r & 1) == (B >> r & 1) ; r--);
	A &= (1LL << r + 1) - 1;
	B &= (1LL << r + 1) - 1;
	int k = r - 1;
	for(; !(B >> k & 1) && ~k; k--);
	ans += (1LL << r + 1) - A;
	if(A > (1LL << k + 1)) ans -= A - (1LL << k + 1);
	printf("%lld\n", ans);
}