#include <bits/stdc++.h>
using namespace std;
int test = 0;
const int MAXN = 200009;
const long long MOD = 998244353;
class {
 public:
  int len;
  long long n, k;
  void solve() {
    cin >> n >> k;
    if (n == k) {
      cout << 1;
      return;
    }
    for (int i = 60; i >= 0; i--) {
      if (n & (1ll << i)) {
        len = i + 1;
        break;
      }
    }
    long long cur = 1, len = 0;
    while (1) {
      if (call(cur << 1) < k) {
        break;
      }
      cur <<= 1;
      len++;
    }
    for (int i = len - 1; i >= 0; --i) {
      if (call(cur | (1ll << i)) >= k) {
        cur |= 1ll << i;
      }
    }
    cout << cur << '\n';
  }
  long long call(long long x) {
    if (x & 1ll) return cal(x);
    return cal(x + 1) + cal(x);
  }
  long long cal(long long x) {
    int xlen;
    for (int i = 60; i >= 0; i--) {
      if (x & (1ll << i)) {
        xlen = i + 1;
        break;
      }
    }
    long long res = 0, p = 1;
    while (xlen < len) {
      res += p;
      p <<= 1;
      xlen++;
      x <<= 1;
    }
    if (x <= n) {
      res += min(n - x + 1, p);
    }
    return res;
  }
} NSPACE;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}
