#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long calc(long long x) {
  long long l = x, r = x, an = 0;
  if (l % 2 == 0) r++;
  while (r <= n) {
    an += (r - l + 1);
    l = l * 2;
    r = r * 2 + 1;
  }
  if (l <= n) an += (n - l + 1);
  return an;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  long long l = 1, r = n, mi, an = 1;
  if (n == k) {
    cout << 1 << endl;
    return 0;
  } else if (n == k + 1) {
    cout << 2 << endl;
    return 0;
  }
  if (k == 1) {
    cout << n << endl;
    return 0;
  }
  while (l <= r) {
    mi = (l + r) / 2;
    long long x = calc(mi);
    long long y = calc(mi + 1);
    if (x >= k && y >= k) {
      an = max(an, mi + 1);
      l = mi + 2;
    } else if (y >= k) {
      an = max(an, mi + 1);
      l = mi + 2;
    } else if (x >= k) {
      an = max(an, mi);
      l = mi + 1;
    } else
      r = mi - 1;
    mi = (l + r) / 2;
  }
  cout << an << endl;
  return 0;
}
