#include <bits/stdc++.h>
using namespace std;
const int MAXN = 64 + 20;
long long n, k;
long long getnum(long long l) {
  bool odd = false;
  if (l & 1) odd = true;
  long long ans = 0;
  for (long long i = 1;; i *= 2) {
    if (odd) {
      if (l * i > n) return ans;
      if (l * i + i - 1 > n) return ans + n - l * i + 1;
      ans += i;
    } else {
      if (l * i > n) return ans;
      if (l * i + i * 2 > n) return ans + n - l * i + 1;
      ans += i * 2;
    }
  }
}
int main() {
  cin >> n >> k;
  if (n == k) {
    puts("1");
    return 0;
  }
  if (k == 1) {
    cout << n;
    return 0;
  }
  long long l = 1, r = n / 2;
  while (l < r) {
    long long mid = (l + r + 1) / 2;
    if (getnum(mid * 2) >= k)
      l = mid;
    else
      r = mid - 1;
  }
  long long ans = l * 2;
  l = 1, r = (n + 1) / 2;
  while (l < r) {
    long long mid = (l + r + 1) / 2;
    if (getnum(mid * 2 - 1) >= k)
      l = mid;
    else
      r = mid - 1;
  }
  cout << max(ans, l * 2 - 1) << endl;
}
