#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  long long sn = n;
  long long ans = sn;
  long long shift = -1;
  long long cur_m = 0;
  while (cur_m < k) {
    ++shift;
    sn = (n >> shift);
    cur_m = (1ll << shift) + (n & ((1ll << shift) - 1));
    if (sn % 2 == 0) {
      cur_m += (1ll << shift) - 1;
    }
    if (cur_m >= k) {
      ans = sn;
      break;
    }
    --sn;
    long long prev_m = cur_m;
    if (sn % 2 == 0) {
      cur_m = (1ll << (shift + 1ll)) - 1 + prev_m;
      if (cur_m >= k) {
        ans = sn;
        break;
      }
      --sn;
    }
    cur_m = (1ll << (shift + 1ll)) - 1;
    if (cur_m >= k) {
      ans = sn;
      break;
    }
    --sn;
    if (sn == 0) continue;
    cur_m *= 2;
    if (cur_m >= k) {
      ans = sn;
      break;
    }
  }
  cout << ans << endl;
}
