#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
#pragma GCC target("avx2")
using namespace std;
long long count0(long long n, long long x) {
  if (x > n) return 0;
  long long cnt = 0, bin = 1;
  while (bin * x <= n) {
    if (bin * 2 + x * bin - 1 >= n) {
      cnt += n - x * bin + 1;
      return cnt;
    } else {
      cnt += bin * 2;
    }
    bin *= 2;
  }
  return cnt;
}
long long count1(long long n, long long x) {
  if (x > n) return 0;
  long long cnt = 0, bin = 1;
  while (bin * x <= n) {
    if (bin + x * bin - 1 >= n) {
      cnt += n - x * bin + 1;
      return cnt;
    } else {
      cnt += bin;
    }
    bin *= 2;
  }
  return cnt;
}
signed main() {
  long long n, k;
  cin >> n >> k;
  long long l = 0, r = n + 1, res = 0;
  while (r > l + 1) {
    long long mid = (r + l) / 2;
    if (count0(n, 2 * mid) >= k) {
      res = max(res, 2 * mid);
      l = mid;
    } else
      r = mid;
  }
  long long ll = 0, rr = n + 1;
  while (rr > ll + 1) {
    long long mid = (rr + ll) / 2;
    if (count1(n, 2 * mid - 1) >= k) {
      res = max(res, 2 * mid - 1);
      ll = mid;
    } else
      rr = mid;
  }
  cout << res << " ";
}
