#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,m,ans;
int main()
{
    scanf("%lld%lld",&n,&m);
    if(n==m){
        puts("1");
        return 0;
    }
    ll p=60;
    while(p>=0&&(n>>p)%2==(m>>p)%2)
        p--;
    n&=(1ll<<(p+1))-1;
    m&=(1ll<<p)-1;
    ans+=(1ll<<p)-n;
    int s=0;
    while(m){
        s++;
        m>>=1;
    }
    ans+=1ll<<s;
    n=max(n,1ll<<s);
    ans+=(1ll<<p)-n;
    printf("%lld\n",ans);
}
