#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k, ans = 1, p, temp;
  cin >> n >> k;
  if (n == k) {
    cout << 1;
    return 0;
  }
  if (k == 1) {
    cout << n;
    return 0;
  }
  long long s, e, m;
  s = 1, e = (n - 1) / 2;
  while (s <= e) {
    m = (s + e) / 2;
    p = log2((n + 1) / (2 * m + 2)) + 1;
    temp = 2 * ((1LL << p) - 1) + max(1 + n - (1LL << p) * 2 * m, 0LL);
    if (temp >= k) {
      s = m + 1;
      ans = max(ans, 2 * m);
    } else
      e = m - 1;
  }
  s = 0, e = (n - 3) / 4;
  while (s <= e) {
    m = (s + e) / 2;
    p = log2((n + 1) / (4 * m + 4)) + 1;
    temp = 1 + 2 * ((1LL << p) - 1) +
           max(1 + n - (1LL << (p + 1)) * (2 * m + 1), 0LL);
    if (temp >= k) {
      s = m + 1;
      ans = max(ans, 2 * m + 1);
    } else
      e = m - 1;
  }
  cout << ans;
  return 0;
}
