#include <bits/stdc++.h>
using namespace std;
long long odd, p, k, even;
int main() {
  cin >> even >> k;
  p = 1;
  while (p <= k) p *= 2;
  p /= 2;
  odd = (even - (k - p)) / max(1ll, p);
  odd -= (odd + 1) % 2;
  p = 1;
  while (p <= k + 1) p *= 2;
  p /= 4;
  even = (even - (k - 2 * p + 1)) / max(1ll, p);
  even -= (even % 2);
  cout << max(odd, even);
  return 0;
}
