#include <bits/stdc++.h>
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  for (; c > '9' || c < '0'; c = getchar()) {
    if (f == '-') f = -1;
  }
  for (; c >= '0' && c <= '9'; c = getchar()) {
    x = x * 10 + c - '0';
  }
  return x * f;
}
inline bool check(long long x, long long n, long long k) {
  long long res = 0, l = x, r = x;
  if (!(x & 1)) r++;
  for (;;) {
    res += std::min(n, r) - l + 1;
    l <<= 1;
    r = (r << 1) + 1;
    if (l > n) break;
  }
  return res >= k;
}
inline void work() {
  long long n = read(), k = read(), ans = 0;
  for (long long l = 1, r = n + 1 >> 1; l <= r;) {
    long long mid = l + r >> 1;
    if (check((mid << 1) - 1, n, k)) {
      ans = (mid << 1) - 1;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  for (long long l = 1, r = n >> 1; l <= r;) {
    long long mid = l + r >> 1;
    if (check(mid << 1, n, k)) {
      ans = std::max(ans, mid << 1);
      l = mid + 1;
    } else
      r = mid - 1;
  }
  printf("%I64d\n", ans);
}
int32_t main() {
  work();
  return 0;
}
