#include <bits/stdc++.h>
using namespace std;
long long dp[(int)(1e5 + 4)], n, k, sol;
map<long long, int> m;
long long calc(long long x) {
  if (!x) return 2e18;
  long long sol = 0, id = 2 - x % 2;
  while (x <= n) {
    sol += id;
    x <<= 1;
    id <<= 1;
  }
  x >>= 1;
  id >>= 1;
  sol -= max(x + id - n - 1, 0LL);
  return sol;
}
long long solve(bool odd) {
  long long l = -1, r = n / 2 + 3, mid;
  while (r - l > 1) {
    mid = (r + l) >> 1;
    if (calc((mid << 1) + odd) >= k)
      l = mid;
    else
      r = mid;
  }
  return (l << 1) + odd;
}
int main() {
  cin >> n >> k;
  sol = max(sol, solve(1));
  sol = max(sol, solve(0));
  cout << sol;
  return 0;
}
