#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long bin(long long lo, long long hi, bool even) {
  long long tot = 1;
  while (hi - lo > 2) {
    long long mid = (hi + lo) / 2;
    if (mid % 2 == 0 && !even) mid--;
    if (mid % 2 == 1 && even) mid--;
    long long pwrs = 1, curr = mid;
    tot = 0;
    if (even) pwrs++;
    while (tot < k && curr <= n) {
      tot += min(pwrs, n - curr + 1);
      pwrs <<= 1;
      curr <<= 1;
    }
    if (tot >= k)
      lo = mid;
    else
      hi = mid;
  }
  return lo;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  long long lo = 1, hi = n - (1 - n % 2) + 2;
  cout << max(bin(lo, hi, false), bin(0, n - n % 2 + 2, true));
  return 0;
}
