#include <bits/stdc++.h>
using namespace std;
long long n, k;
bool judge(long long x) {
  long long l = x, r = x;
  long long res = 0;
  if (x % 2 == 0) r++;
  while (1) {
    res += min(r - l + 1, n - l + 1);
    l = l << 1;
    r = (r << 1) + 1;
    if (l > n) break;
  }
  return res >= k;
}
int main() {
  scanf("%lld%lld", &n, &k);
  long long l = 1, r = (n + 1) / 2;
  long long ans = 0;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (judge(2 * mid - 1))
      ans = 2 * mid - 1, l = mid + 1;
    else
      r = mid - 1;
  }
  l = 1, r = n / 2;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (judge(2 * mid))
      ans = max(ans, 2 * mid), l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%lld\n", ans);
  return 0;
}
