#include <bits/stdc++.h>
using namespace std;
long long getOccCount(long long x, long long n) {
  long long ans = 0;
  for (int i = 0; x <= n; i++) {
    long long y = (1ll << i);
    ans += min(n - x + 1, y);
    x <<= 1;
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long ans = 1;
  for (int i = 0; i < 2; i++) {
    long long l = 0, r = 2e18;
    while (r - l > 1) {
      long long p = (l + r) >> 1, ct = getOccCount((p << 1) | i, n);
      if (i == 0) ct += getOccCount((p << 1) | 1, n);
      if (ct >= k)
        l = p;
      else
        r = p;
    }
    if (l) {
      ans = max(ans, (l << 1) | i);
    }
  }
  cout << ans << "\n";
  return 0;
}
