#include <bits/stdc++.h>
using namespace std;
void prb(int upper) {
  for (int i = 10; i >= 0; i--) {
    if ((upper & (1 << i)) > 0)
      cout << 1;
    else
      cout << 0;
  }
  cout << '\n';
}
long long n, k;
long long cnt(long long K) {
  long long lower = K;
  long long upper = K + (K % 2 == 0 ? 1 : 0);
  long long tot = 0;
  while (upper <= n) {
    tot += upper - lower + 1;
    lower = lower << 1;
    upper = (upper << 1) + 1;
  }
  upper = min(upper, n);
  tot += max(upper - lower + 1, 0LL);
  return tot;
}
long long solveeven() {
  long long r = n;
  if (r & 1 != 0) r--;
  long long l = 1;
  r = r / 2;
  while (l < r) {
    long long m = l + (r - l + 1) / 2;
    m = m * 2;
    if (cnt(m) >= k) {
      l = m / 2;
    } else {
      r = m / 2 - 1;
    }
  }
  if (cnt(2 * l) < k) return 0;
  return l * 2;
}
long long solveodd() {
  long long r = n;
  if (r & 1 == 0) r--;
  long long l = 0;
  r = r / 2;
  while (l < r) {
    long long m = (l) + (r - l + 1) / 2;
    m = m * 2 + 1;
    if (cnt(m) >= k) {
      l = m / 2;
    } else {
      r = m / 2 - 1;
    }
  }
  return l * 2 + 1;
}
int main() {
  cin >> n >> k;
  long long ans = 0;
  ans = max(solveeven(), solveodd());
  cout << ans << '\n';
}
