#include <bits/stdc++.h>
using namespace std;
function<void(void)> ____ = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
};
using LL = int_fast64_t;
LL n, k;
bool check(LL mid, bool tag) {
  LL tot = 0;
  int p = 0;
  while (mid * (1ll << (p + 1)) <= n) p++;
  for (int i = 0; i < p; i++) tot += (1ll << i);
  tot += min(1ll << p, n - mid * (1ll << p) + 1);
  if (tag) tot--;
  return tot >= k;
}
LL gaoodd() {
  LL pl = 1, pr = n & 1 ? n : n - 1;
  LL l = (pl + 1) >> 1, r = (pr + 1) >> 1;
  while (l <= r) {
    LL mid = (l + r) >> 1;
    if (check(mid * 2ll - 1, false))
      l = mid + 1;
    else
      r = mid - 1;
  }
  return (r << 1) - 1;
}
LL gaoeven() {
  LL pl = 2, pr = n & 1 ? n - 1 : n;
  LL l = pl >> 1, r = pr >> 1;
  if (pl > pr) return 0;
  while (l <= r) {
    LL mid = (l + r) >> 1;
    if (check(mid, true))
      l = mid + 1;
    else
      r = mid - 1;
  }
  return r << 1;
}
int main() {
  cin >> n >> k;
  cout << max(gaoodd(), gaoeven()) << endl;
  return 0;
}
