#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long depth = 0;
long long calc(long long x) {
  if (x > n) return 0;
  if (x % 2) {
    x *= 2;
    return 1 + calc(x);
  }
  long long ans = 0;
  long long size = 2;
  while (x <= n) {
    long long r = min(x + size - 1, n);
    ans += r - x + 1;
    size *= 2;
    x *= 2;
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ;
  cin >> n >> k;
  if (n == k) {
    cout << 1 << "\n";
    return 0;
  }
  if (n == 1) {
    cout << 1 << "\n";
    return 0;
  }
  long long mx = 1;
  {
    long long l = 0;
    long long r = n / 2 + 1;
    while (l < r) {
      long long m = (l + r) / 2;
      long long i = (m * 2);
      if (calc(i) >= k)
        l = m + 1;
      else
        r = m;
    }
    long long m = l - 1;
    mx = max(mx, m * 2);
  }
  {
    long long l = 0;
    long long r = n / 2 + 1;
    while (l < r) {
      long long m = (l + r) / 2;
      long long i = (m * 2 + 1);
      if (calc(i) >= k)
        l = m + 1;
      else
        r = m;
    }
    long long m = l - 1;
    mx = max(mx, m * 2 + 1);
  }
  cout << mx << "\n";
}
