#include <bits/stdc++.h>
using namespace std;
long long count(long long s, long long l) {
  long long i = 1, ans = 0;
  if (s % 2 == 0) {
    i = 2;
  }
  while (s + i - 1 <= l) {
    ans += i;
    i *= 2;
    s *= 2;
  }
  long long t = max(0ll, l - s + 1);
  return ans + t;
}
int main() {
  long long n, k, j, h = 0, l, p, b = 1, a = 1, mid, i;
  cin >> n >> k;
  i = 1, j = n;
  while (i <= j) {
    mid = (i + j) / 2;
    if (mid % 2 != 0) mid++;
    if (count(mid, n) >= k) {
      a = mid;
      i = mid + 2;
    } else
      j = mid - 2;
    h++;
    if (h > 1000) break;
  }
  i = 1, j = n;
  while (i <= j) {
    mid = (i + j) / 2;
    if (mid % 2 == 0) mid++;
    if (count(mid, n) >= k) {
      b = mid;
      i = mid + 2;
    } else
      j = mid - 2;
    h++;
    if (h > 2000) break;
  }
  cout << max(a, b);
}
