#include <bits/stdc++.h>
const int maxn = 100010;
const int inf = 1e9;
const long long mod = 1e9 + 7;
using namespace std;
long long n, m, k;
long long check(long long m) {
  long long s = 0, a = 1;
  if (m % 2 == 1) {
    while (m * a <= n) {
      if (n >= m * a + a - 1) {
        s += a;
        a *= 2;
      } else {
        s += n - m * a + 1;
        a *= 2;
      }
    }
  } else {
    while (m * a <= n) {
      if (n >= m * a + a * 2 - 1) {
        s += a * 2;
        a *= 2;
      } else {
        s += n - m * a + 1;
        a *= 2;
      }
    }
  }
  return s;
}
int main() {
  cin >> n >> k;
  long long l = 1, r = n + 1;
  while (r - l > 1) {
    m = (l + r) / 2;
    if (check(m) >= k)
      l = m;
    else if (m % 2 == 1 && m < r - 1 && check(m + 1) >= k)
      l = m + 1;
    else
      r = m;
  }
  cout << l << endl;
  return 0;
}
