#include <bits/stdc++.h>
using namespace std;
long long int saa(long long int x, long long int n) {
  if (x > n) {
    return 0;
  }
  long long int ans = 0;
  long long int i = 1;
  for (; i * x <= n; i *= 2) {
    ans += min(n, i * (x + 1) - 1) - i * x + 1;
  }
  return ans;
}
long long int sa(long long int x, long long int n) {
  if (x % 2 == 0) {
    return saa(x, n) + saa(x + 1, n);
  }
  return saa(x, n);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n = 0, k = 0;
  cin >> n >> k;
  long long int temp = n;
  long long int res = 1;
  while (temp > 0) {
    for (int i = 0; i <= 3; i++) {
      if (temp - i > 0) {
        if (sa(temp - i, n) >= k) {
          res = max(res, temp - i);
          break;
        }
      }
    }
    if (res != 1) {
      break;
    }
    temp = temp / 2;
  }
  cout << res << endl;
  return 0;
}
