#include<bits/stdc++.h>
using namespace std;
#define int long long
int l,r;
signed main(){
	scanf("%lld%lld",&l,&r);
	if (l==r){
		puts("1");
		return 0;
	}
	long long h=1;
	while (h*2<=(l^r))h*=2;
	l&=h+h-1;r&=h+h-1;
	long long p=1;
	while (p<=r-h)p*=2;
	printf("%lld\n",h-l+(p>l?h:h-l+p));
	return 0;
}