#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long check(long long x) {
  long long a, b, ans = 0;
  if (x & 1ll)
    a = b = x;
  else
    a = x, b = x + 1;
  while (a <= n) {
    ans += min(n, b) - a + 1;
    a = a * 2;
    b = b * 2 + 1;
  }
  return ans;
}
int main() {
  scanf("%I64d%I64d", &n, &k);
  long long L = 1, R = n / 2 + (n & 1), res = -1;
  while (L <= R) {
    long long mid = (L + R) >> 1;
    if (check(mid * 2 - 1) >= k) {
      L = mid + 1;
      res = max(res, mid * 2 - 1);
    } else
      R = mid - 1;
  }
  L = 1, R = n / 2;
  while (L <= R) {
    long long mid = (L + R) >> 1;
    if (check(mid << 1) >= k) {
      L = mid + 1;
      res = max(res, mid << 1);
    } else
      R = mid - 1;
  }
  printf("%I64d\n", res);
}
