#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_B=60;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B; cin >> A >> B;
    if (A==B){cout << 1 << '\n'; return 0;}
    int MSB;
    for (MSB=MAX_B-1;MSB>=0;--MSB){
        if (!(A&1LL<<MSB)&&(B&1LL<<MSB)) break;
    }
    A&=(1LL<<(MSB+1))-1,B&=(1LL<<(MSB+1))-1;
    int MSB2;
    for (MSB2=MSB-1;MSB2>=0;--MSB2){
        if (B&1LL<<MSB2) break;
    }
    ll C=(1LL<<MSB)+(1LL<<(MSB2+1))-1;
    ll ans=C-A+1+(1LL<<(MSB+1))-max(C+1,A+(1LL<<MSB));
    cout << ans << '\n';
}