#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
string itos(int n) {
  stringstream ss;
  ss << n;
  string second = ss.str();
  return second;
}
long long ppow(long long x, long long y, long long mod) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % mod;
    y >>= 1;
    x = x * x % mod;
  }
  return res;
}
int main() {
  cout << fixed << setprecision(10);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long l = 0, r = n;
  while (l < r) {
    long long m = (l + r + 1) / 2;
    long long x = m * 2;
    long long y = x + 1;
    long long cur = 0;
    while (x <= n) {
      cur += min(y, n) - x + 1;
      x = x * 2;
      y = y * 2 + 1;
    }
    if (cur >= k) {
      l = m;
    } else {
      r = m - 1;
    }
  }
  long long ans1 = l + l;
  l = 0, r = n;
  while (l < r) {
    long long m = (l + r + 1) / 2;
    long long x = m + m + 1;
    long long y = m + m + 1;
    long long cur = 0;
    while (x <= n) {
      cur += min(y, n) - x + 1;
      x = x + x;
      y = y + y + 1;
    }
    if (cur >= k) {
      l = m;
    } else {
      r = m - 1;
    }
  }
  long long ans2 = l + l + 1;
  cout << max(ans1, ans2);
}
