#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

LL a,b,bin[65];

int main()
{
	scanf("%lld%lld",&b,&a);
	if (a==b) {puts("1");return 0;}
	bin[0]=1;
	for (int i=1;i<=60;i++) bin[i]=bin[i-1]*2;
	int d=60;
	while ((a&bin[d])==(b&bin[d])) d--;
	a&=bin[d+1]-1;b&=bin[d+1]-1;
	int k=d-1;
	while (k>=0&&!(a&bin[k])) k--;
	LL l1=b,r1=bin[d]+bin[k+1]-1,l2=bin[d]+b,r2=bin[d+1]-1;
	l2=max(l2,r1+1);
	printf("%lld",r1-l1+1+max((LL)0,r2-l2+1));
	return 0;
}