#include <bits/stdc++.h>
using namespace std;
long long denom = 1e9 + 7;
long long n, k;
unordered_map<long long, long long> mp;
long long calc(long long m) {
  if (m == 1) return n;
  if (m > n) return 0;
  if (m == n) return 1;
  long long res = 0;
  if (m % 2 == 0) {
    long long p = 1;
    long long a = 2;
    res = 2;
    while (true) {
      m *= 2;
      if (m > n) break;
      a *= 2;
      p++;
      res += min(n, m + a - 1) - m + 1;
    }
  } else {
    res = 1 + calc(2 * m);
  }
  return res;
}
bool fit(long long m) { return calc(m) >= k; }
int main(int argc, const char* argv[]) {
  cin >> n >> k;
  long long l = 1;
  long long h = n;
  while (l + 1 < h) {
    long long mid = l + (h - l) / 2;
    if (fit(mid + 1)) {
      l = mid + 1;
    } else {
      if (fit(mid)) {
        l = mid;
      } else {
        h = mid - 1;
      }
    }
  }
  cout << (fit(h) ? h : l);
  return 0;
}
