#include <bits/stdc++.h>
using namespace std;
long long add(long long a, long long b) {
  a += b;
  if (a >= 1000000007) {
    a -= 1000000007;
  }
  return a;
}
long long sub(long long a, long long b) {
  a -= b;
  if (a < 0) {
    a += 1000000007;
  }
  return a;
}
long long mul(long long a, long long b) { return (a * b) % 1000000007; }
void add_self(long long& a, long long b) { a = add(a, b); }
void sub_self(long long& a, long long b) { a = sub(a, b); }
void mul_self(long long& a, long long b) { a = mul(a, b); }
const long long MAXN = 200010;
long long get(long long val, long long tot) {
  long long ans = 0;
  long long L = val, R = val + 1 - (val % 2);
  while (R <= tot) {
    ans += R - L + 1;
    L = 2 * L;
    R = 2 * R + 1;
  }
  ans += max(0LL, tot - L + 1);
  return ans;
}
int main() {
  long long x, k;
  cin >> x >> k;
  long long lo = 0, hi = 1e18, ans = 0;
  while (lo <= hi) {
    long long mid = (lo + hi) / 2;
    if (get(2 * mid + 1, x) >= k) {
      ans = 2 * mid + 1;
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  lo = 0;
  hi = 1e18;
  while (lo <= hi) {
    long long mid = (lo + hi) / 2;
    if (get(2 * mid, x) >= k) {
      ans = max(ans, 2 * mid);
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  cout << ans << "\n";
}
