#include <bits/stdc++.h>
using namespace std;
long long n, k;
inline long long Read() {
  long long num = 0, op = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') op = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    num = num * 10 + ch - '0';
    ch = getchar();
  }
  return num * op;
}
inline long long Calculate(long long x) {
  long long res = 0, tmp = 1;
  while (x <= n) {
    res += min(tmp, n - x + 1);
    x <<= 1;
    tmp <<= 1;
  }
  return res;
}
signed main() {
  n = Read(), k = Read();
  long long ans = -1;
  long long l = 1, r = n / 2, res = -1;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (Calculate(mid * 2) + Calculate(mid * 2 + 1) >= k) {
      res = mid * 2;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  ans = max(ans, res);
  l = 1, r = (n + 1) / 2, res = -1;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (Calculate(mid * 2 - 1) >= k) {
      res = mid * 2 - 1;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  ans = max(ans, res);
  printf("%lld", ans);
  return 0;
}
