#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long count(long long a) {
  long long s = 0;
  for (int i = 0; a <= n; a <<= 1) s += min(n - a + 1, 1LL << i++);
  return s;
}
long long solve(long long a) {
  long long s = count(a);
  if ((a & 1) == 0) s += count(a ^ 1);
  return s;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  long long sol = -1;
  for (int d : {0, 1}) {
    long long lo = 0, hi = n / 2 + 1;
    while (lo + 1 < hi) {
      long long mid = (lo + hi) / 2;
      if (solve(mid * 2 + d) >= k)
        lo = mid;
      else
        hi = mid;
    }
    sol = max(sol, lo * 2 + d);
  }
  cout << sol;
  return 0;
}
