#include <bits/stdc++.h>
using namespace std;
long long ocheck(long long num, long long n, long long k) {
  long long ans = 1;
  long long curr = 2 * num;
  long long mul = 2;
  while (num * mul + mul - 1 <= n) {
    long long add = min(2 * mul * num - curr, mul);
    ans += add;
    mul *= 2;
    curr = num * mul;
  }
  long long tt = 0;
  long long add = max(n - curr + 1, tt);
  ans += add;
  return ans;
}
long long echeck(long long num, long long n, long long k) {
  long long ans = 1;
  if (num + 1 <= n) ans++;
  long long curr = 2 * num;
  long long mul = 2;
  while (num * mul + 2 * mul - 1 <= n) {
    long long add = min(2 * mul * num - curr, 2 * mul);
    ans += add;
    mul *= 2;
    curr = num * mul;
  }
  long long tt = 0;
  long long add = max(n - curr + 1, tt);
  ans += add;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    long long n, k;
    cin >> n >> k;
    long long min = 1;
    long long maxi = n;
    if (n % 2 == 0) maxi--;
    long long mid = (min + maxi) / 2;
    while (min <= maxi) {
      mid = (min + maxi) / 2;
      if (mid % 2 == 0) mid--;
      mid = max(mid, min);
      long long ans = 0;
      ans = ocheck(mid, n, k);
      if (ans >= k)
        min = mid + 2;
      else
        maxi = mid - 2;
    }
    long long one = min - 2;
    min = 2;
    maxi = n;
    if (n % 2 != 0) maxi--;
    mid = (min + maxi) / 2;
    while (min <= maxi) {
      mid = (min + maxi) / 2;
      if (mid % 2 != 0) mid--;
      mid = max(mid, min);
      long long ans = 0;
      ans = echeck(mid, n, k);
      if (ans >= k)
        min = mid + 2;
      else
        maxi = mid - 2;
    }
    long long two = min - 2;
    cout << max(one, two);
  }
  return 0;
}
