#include <bits/stdc++.h>
using namespace std;
long long n, k, ans;
bool chk_odd(long long lim) {
  long long get = 0, bas = 1, val = lim * 2 + 1;
  for (int i = 1; i <= 60; ++i, bas *= 2) {
    long long start = val * bas;
    if (start > n) break;
    get += min(bas, n - start + 1);
  }
  return get >= k;
}
void Solve_Odd() {
  long long l = 0, r = (n & 1) ? n / 2 : n / 2 - 1;
  while (l < r) {
    long long mid = (l + r) / 2;
    if (chk_odd(mid + 1))
      l = mid + 1;
    else
      r = mid;
  }
  if (l == r && chk_odd(l)) ans = max(ans, 2 * l + 1);
}
bool chk_even(long long lim) {
  long long get = 0, bas = 1, val = lim * 2;
  for (int i = 1; i <= 60; ++i, bas *= 2) {
    long long start = val * bas;
    if (start > n) break;
    get += min(bas * 2, n - start + 1);
  }
  return get >= k;
}
void Solve_Even() {
  long long l = 1, r = n / 2;
  while (l < r) {
    long long mid = (l + r) / 2;
    if (chk_even(mid + 1))
      l = mid + 1;
    else
      r = mid;
  }
  if (l == r && chk_even(l)) ans = max(ans, 2 * l);
}
int main() {
  scanf("%lld%lld", &n, &k);
  Solve_Odd(), Solve_Even();
  printf("%lld", ans);
  return 0;
}
