#include <bits/stdc++.h>
using namespace std;
long long numbit(long long x) { return (1LL << x) - 1LL; }
long long getbit(long long x, long long i) { return (x >> i) & 1LL; }
long long onbit(long long x, long long i) { return x | (1LL << i); }
long long offbit(long long x, long long i) { return x & (~(1LL << i)); }
int newMaskNULL(int mask, int m) { return (mask << 1) % (1 << m); }
int newMask(int mask, int m) { return ((mask << 1) % (1 << m)) | 1; }
const long long Inf64 = 1e18;
const long long Inf = 1e9;
const int Nmax = 1e5 + 10;
const long long Mod9 = 1e9 + 9;
const long long Mod7 = 1e9 + 7;
int main() {
  long long n, k;
  cin >> n >> k;
  long long odd, even;
  even = n / 2;
  odd = n - even;
  long long l, r, mid;
  l = 1;
  r = odd;
  long long r1, r2;
  r1 = -1;
  while (l <= r) {
    mid = (l + r) / 2;
    long long d = 0;
    long long tmp = 1;
    bool ok = true;
    while (ok) {
      if (((1 + (mid - 1) * 1LL * 2) * 1LL * tmp) > n) break;
      if ((1 + (mid - 1) * 1LL * 2) * 1LL * tmp + tmp - 1 <= n)
        d += tmp;
      else {
        d += n - (1 + (mid - 1) * 2) * tmp + 1;
        break;
      }
      tmp *= 2;
      if (d >= k) break;
    }
    if (d >= k) {
      r1 = 1 + (mid - 1) * 2;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  l = 1;
  r = even;
  r2 = -1;
  while (l <= r) {
    mid = (l + r) / 2;
    long long d = 0;
    long long tmp = 1;
    bool ok = true;
    while (ok) {
      if (2 * 1LL * mid * 1LL * tmp > n) break;
      if (2 * 1LL * mid * 1LL * tmp + 2 * 1LL * tmp - 1 <= n)
        d += 2 * tmp;
      else {
        d += n - 2 * mid * tmp + 1;
        break;
      }
      tmp *= 2;
      if (d >= k) break;
    }
    if (d >= k) {
      r2 = mid * 2;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  cout << max(r1, r2);
}
