#include <bits/stdc++.h>
using namespace std;

long long a, b;

long long solve();

int main() {
  cin >> a >> b;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0, dig = 0, x, cnt = 0;
  while ((1LL << (dig + 1)) <= b) ++dig;
  while (b && (a >> dig & 1) == (b >> dig & 1)) {
    a &= (1LL << dig) - 1;
    b &= (1LL << dig) - 1;
    --dig;
  }
  if (b == 0) return 1;
  res = (1LL << dig) - a;
  x = b - (1LL << dig);
  while (x) x >>= 1, ++cnt;
  res += min(1LL << dig, res + (1LL << cnt));
  return res;
}