#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
  ll a; cin >> a;
  ll b; cin >> b;
  if(a == b){
    cout << 1 << "\n"; return 0;
  }
  //drop the LCP
  int k = -1;
  for(int i = 60; i >= 0; i--){
    if((a & (1LL<<i)) == (b & (1LL<<i))){
      continue;
    }
    else{
      k = i;
      break;
    }
  }
  a = a % (1LL<<k+1);
  b = b % (1LL<<k+1);
  ll c = b - (1LL<<k);
  int r = -1;
  for(int i=0;i<60;i++){
    if((1LL<<i)-1 >= c){
      r = i;
      break;
    }
  }
  ll g = (1LL<<r) - 1;
  if(g < a){
    cout << 2 * ((1LL<<k) - a) + (1LL<<r) << "\n";
  }
  else{
    //you can get everything from a to 1LL<<k, exclusive on the right.
    cout << (1LL<<k+1) - a << "\n";
  }
}
