#include <cstdio>

unsigned long long a,b,c,d;

int main(void)
{
    int i,j,k;

    //freopen("x.in","r",stdin);

    scanf("%llu %llu",&a,&b);
    if(a == b)
        return puts("1"),0;

    d = b - a + 1;
    for(i = 63;i >= 0;--i)
    {
        if((a & (1ull << i)) == (b & (1ull << i)))
            continue;
        a &= (1ull << i) - 1;
        b &= (1ull << i) - 1;
        for(j = i - 1;j >= 0;--j)
        {
            if(!(b & (1ull << j)))
                continue;
            c = 1ull << (j + 1);
            --c;
            break;
        }
        if(c >= a)
            d += 1ull << i;
        else
            d += (1ull << i) - a + c + 1;
        d -= b + 1;
        break;
    }
    printf("%llu\n",d);

    return 0;
}