#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long mm = 0, res = 0;
  long long left = 2, right = (n / 2) * 2;
  long long lax = 0;
  while (left < right) {
    long long mid = (left + right + 2) / 2;
    mid = (mid / 2) * 2;
    long long sat = mid, uta = mid + 1;
    long long cost = 0;
    while (sat <= n) {
      cost += max(0LL, min(n, uta) - sat + 1);
      sat *= 2;
      uta *= 2;
      uta++;
    }
    if (cost < k) {
      right = mid - 2;
    } else {
      left = mid;
    }
    lax = cost;
  }
  res = left;
  if (k == n) res = 0;
  left = 1, right = n;
  if (right % 2 == 0) right--;
  while (left < right) {
    long long mid = (left + right + 2) / 2;
    if (mid % 2 == 0) mid--;
    long long sat = mid, uta = mid;
    long long cost = 0;
    while (sat <= n) {
      cost += max(0LL, min(n, uta) - sat + 1);
      sat *= 2;
      uta *= 2;
      uta++;
    }
    if (cost < k) {
      right = mid - 2;
    } else {
      left = mid;
    }
  }
  res = max(res, left);
  cout << res << "\n";
  return 0;
}
