#include <bits/stdc++.h>
using namespace std;
long long int const mod = 1000000007;
long long int gcdfun(long long int a, long long int b) {
  if (b == 0) return a;
  a %= b;
  return gcdfun(b, a);
}
long long int power(long long int x, long long int y, long long int m) {
  long long int temp;
  if (y == 0) return 1;
  temp = power(x, y / 2, m) % m;
  if (y % 2 == 0)
    return ((temp) * (temp)) % m;
  else
    return (((x) % m) * ((temp * temp) % m)) % m;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, k;
  cin >> n >> k;
  long long int lo = 1;
  long long int hi = n;
  while (lo + 4 < hi) {
    long long int mid = lo + (hi - lo) / 2;
    long long int num = 0;
    if (mid % 2 && mid > 1) mid--;
    num = 2;
    long long int temp = mid * 2;
    long long int cnt;
    if (mid % 2)
      cnt = 2;
    else
      cnt = 4;
    while (temp <= n) {
      num += (min(cnt, n - temp + 1));
      cnt *= 2;
      temp *= 2;
    }
    if (num >= k) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  for (long long int i = hi; i >= lo; i--) {
    if (i > n) continue;
    long long int num = 0;
    if (i % 2)
      num = 1;
    else
      num = 2;
    long long int temp = i * 2;
    long long int cnt;
    if (i % 2)
      cnt = 2;
    else
      cnt = 4;
    while (temp <= n) {
      num += (min(cnt, n - temp + 1));
      cnt *= 2;
      temp *= 2;
    }
    if (num >= k) {
      cout << i << "\n";
      return 0;
    }
  }
}
