#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
long long n, k;
long long calc(long long x) {
  long long y = 0, tmp = n;
  int diff = 0;
  while ((int)log2(x) < (int)log2(tmp)) {
    if (tmp & 1) {
      y |= ((long long)1 << diff);
    }
    tmp >>= 1;
    diff++;
  }
  if (tmp > x) {
    return ((long long)1 << (diff + 1)) - 1;
  } else if (tmp < x) {
    return ((long long)1 << diff) - 1;
  } else {
    return ((long long)1 << diff) + y;
  }
}
bool valid(long long val) { return calc(val) + calc(val + 1) >= k; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  long long l = 0, r = n / 2;
  while (l < r) {
    long long mid = l + (r - l + 1) / 2;
    if (valid(2 * mid)) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  long long ans = 2 * l;
  cout << (calc(ans + 1) >= k ? ans + 1 : ans) << '\n';
}
