#include <bits/stdc++.h>

#define mp make_pair
#define pb push_back

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef vector<int> vi;

i64 a, b;

int main()
{
  cin >> a >> b;
  if (a == b) {
    cout << 1 << endl;
    return 0;
  }
  i64 c = 0;
  int i = 60;
  while ((a & (1LL << i)) == (b & (1LL << i))) i--;
  a &= (1LL << (i+1)) - 1;
  b &= (1LL << (i+1)) - 1;
  c += (1LL << i) - a;
  int k = i-1;
  while (k >= 0 && (b & (1LL << k)) == 0) k--;
  c += 1LL << (k+1);
  c += (1LL << (i+1)) - ((1LL << i) + a);
  c -= (1LL << (k+1)) - 1 >= a ? (1LL << (k+1)) - a : 0;

  cout << c << endl;

  return 0;
}
