#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
long long n, k;
int check(long long x) {
  long long ans = 0, a, b;
  if (x % 2 == 1 && x <= n) {
    ans += 1;
    a = x, b = x;
    while (1) {
      a = a * 2;
      b = b * 2 + 1;
      if (b <= n)
        ans += b - a + 1;
      else {
        if (a > n)
          break;
        else {
          ans += n - a + 1;
          break;
        }
      }
    }
    if (ans >= k) return 1;
    return 0;
  }
  if (x == n - 1) return 2 >= k;
  if (x % 2 == 0 && x <= n) {
    ans += 2;
    a = x, b = x + 1;
    while (1) {
      a = a * 2;
      b = b * 2 + 1;
      if (b <= n)
        ans += b - a + 1;
      else {
        if (a > n)
          break;
        else {
          ans += n - a + 1;
          break;
        }
      }
    }
  }
  if (ans >= k) return 1;
  return 0;
}
int main() {
  scanf("%lld%lld", &n, &k);
  long long l = 1, r = n, mid, ans = 0;
  while (l <= r) {
    mid = (l + r) / 2;
    if (check(2 * mid)) {
      l = mid + 1;
    } else
      r = mid - 1;
  }
  ans = max(ans, (l - 1) * 2);
  l = 1, r = n, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (check(2 * mid - 1)) {
      l = mid + 1;
    } else
      r = mid - 1;
  }
  ans = max(ans, (l - 1) * 2 - 1);
  printf("%lld\n", ans);
}
