#include <bits/stdc++.h>
using namespace std;
long long n, k;
inline long long check(long long x) {
  queue<pair<long long, long long> > p;
  if (x & 1)
    p.push(make_pair(x, x));
  else
    p.push(make_pair(x, x + 1));
  long long ans = 0;
  while (p.size()) {
    pair<long long, long long> zz = p.front();
    p.pop();
    ans += min(zz.second, n) - zz.first + 1;
    if ((zz.first << 1) <= n)
      p.push(make_pair(zz.first << 1, zz.second << 1 | 1));
  }
  return ans;
}
int main() {
  scanf("%lld%lld", &n, &k);
  long long l = 1, r = n / 2ll;
  long long ans = 0;
  while (l <= r) {
    long long mid = l + r >> 1ll;
    long long cnt = check(mid << 1);
    if (cnt >= k) {
      ans = max(ans, mid << 1);
      l = mid + 1ll;
    } else
      r = mid - 1;
  }
  l = 0, r = n / 2ll;
  while (l <= r) {
    long long mid = l + r >> 1ll;
    long long cnt = check(mid << 1 | 1);
    if (cnt >= k) {
      ans = max(ans, mid << 1 | 1);
      l = mid + 1;
    } else
      r = mid - 1;
  }
  cout << ans << endl;
}
