#include <bits/stdc++.h>
using namespace std;
int const N = 2005;
long long f(long long x, long long n) {
  long long t = (x % 2 == 1 ? 1 : 2);
  long long h = 1;
  long long res = 0;
  while (true) {
    if ((x * h) > n) return res;
    res += (t - (x * h + t - 1 - min(x * h + t - 1, n)));
    t <<= 1;
    h <<= 1;
  }
  return res;
}
long long bs(long long t, long long n, long long k) {
  long long l = (t ? t : 2), r = (n % 2 == t ? n : n - 1);
  long long res = 0;
  while (l <= r) {
    long long md = (l + r) / 2;
    md = (md % 2 == t ? md : md - 1);
    long long x = f(md, n);
    if (x >= k) {
      res = max(res, md);
      l = md + 2;
    } else
      r = md - 2;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  cout << max(bs(0, n, k), bs(1, n, k)) << endl;
  return 0;
}
