#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, ans1 = 0, ans2 = 0;
  scanf("%lld%*c", &n), scanf("%lld%*c", &k);
  long long low = 2, hi = (n & 1) ? n - 1 : n;
  while (low <= hi) {
    long long mid = (low + hi) / 2, temp = 0, val, point;
    if (mid & 1) {
      mid++;
    }
    temp++;
    if (mid + 1 <= n) temp++;
    val = 2, point = mid;
    while (point < n) {
      point *= 2;
      val *= 2;
      if (point > n) {
        break;
      } else if (point + (val - 1) <= n) {
        temp += val;
      } else {
        temp += (n - point + 1);
      }
    }
    if (temp >= k) {
      ans1 = mid;
      low = (mid + 2);
    } else {
      hi = mid - 2;
    }
  }
  low = 1, hi = n;
  while (low <= hi) {
    long long mid = (low + hi) / 2, temp = 0, val, point;
    if (mid & 1) {
      temp++;
      val = 1, point = mid;
    } else {
      temp++;
      if (mid + 1 <= n) temp++;
      val = 2, point = mid;
    }
    while (point < n) {
      point *= 2;
      val *= 2;
      if (point > n) {
        break;
      } else if (point + (val - 1) <= n) {
        temp += val;
      } else {
        temp += (n - point + 1);
      }
    }
    if (temp >= k) {
      ans2 = mid;
      low = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  printf("%lld\n", max(ans1, ans2));
}
