#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long mul[64];
long long get(long long x) {
  int lena;
  for (int i = 1; i < 63; i++) {
    if (mul[i] > n) {
      lena = i;
      break;
    }
  }
  int lenb;
  for (int i = 1; i < 63; i++) {
    if (mul[i] > x) {
      lenb = i;
      break;
    }
  }
  int lenx = lena - lenb;
  long long sa = n / mul[lenx];
  if (sa > x)
    return mul[lenx + 1] - 1;
  else if (sa == x)
    return mul[lenx] + n % mul[lenx];
  else
    return mul[lenx] - 1;
}
long long check(long long x) {
  if (x % 2 == 0 && x < n)
    return get(x) + get(x + 1);
  else
    return get(x);
}
int main() {
  scanf("%lld %lld", &n, &k);
  long long l = 0, r = n / 2;
  mul[0] = 1;
  for (int i = 1; i < 63; i++) mul[i] = mul[i - 1] * 2;
  while (r - l > 1) {
    long long mid = (r + l) >> 1;
    if (check(mid * 2) >= k)
      l = mid;
    else
      r = mid;
  }
  if (check(r * 2 + 1) >= k)
    printf("%lld\n", r * 2 + 1);
  else if (check(r * 2) >= k)
    printf("%lld\n", r * 2);
  else if (check(l * 2 + 1) >= k)
    printf("%lld\n", l * 2 + 1);
  else
    printf("%lld\n", l * 2);
  return 0;
}
