#include <bits/stdc++.h>
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long n, k;
bool check(long long x) {
  long long tmp = x;
  long long cnt = 0;
  long long cur;
  if (x & 1)
    cur = 1;
  else
    cur = 2;
  while (x <= n) {
    cnt += min(cur, n - x + 1);
    x <<= 1;
    cur <<= 1;
  }
  if (cnt >= k) return true;
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  long long l = 0, r = (n - 1) / 2;
  long long ans = 1;
  while (l < r) {
    long long mid = (l + r + 1) >> 1;
    long long x = mid * 2 + 1;
    if (check(x))
      l = mid;
    else
      r = mid - 1;
  }
  ans = max(ans, 2 * l + 1);
  l = 0, r = n / 2;
  while (l < r) {
    long long mid = (l + r + 1) >> 1;
    long long x = mid * 2;
    if (check(x))
      l = mid;
    else
      r = mid - 1;
  }
  ans = max(ans, 2 * l);
  cout << ans << '\n';
  return 0;
}
