#include <bits/stdc++.h>
using namespace std;
long long n, k, mx;
bool ck(long long a) {
  long long l = a, r = a, ret = 0;
  while (1) {
    if (l > n)
      break;
    else if (r < n)
      ret += r - l + 1;
    else if (n <= r && l <= n)
      ret += n - l + 1;
    l = l * 2, r = r * 2 + 1;
  }
  if (a % 2 == 0) {
    l = a + 1, r = a + 1;
    while (1) {
      if (l > n)
        break;
      else if (r < n)
        ret += r - l + 1;
      else if (n <= r && l <= n)
        ret += n - l + 1;
      l = l * 2, r = r * 2 + 1;
    }
  }
  return ret >= k;
}
int main() {
  cin.tie(NULL);
  cin >> n >> k;
  long long l = 0, r = n / 2 + 1;
  while (l + 1 < r) {
    long long md = (l + r) >> 1;
    if (ck(md * 2))
      l = md;
    else
      r = md;
  }
  mx = l * 2;
  l = 0, r = n / 2 + 1;
  while (l + 1 < r) {
    long long md = (l + r) >> 1;
    if (ck(md * 2 + 1))
      l = md;
    else
      r = md;
  }
  cout << max(mx, l * 2 + 1);
  return 0;
}
