#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 5;
const long long int M = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  long long int n, k;
  cin >> n >> k;
  long long int low = 1, high = (1e18) + 1;
  long long int ans = -1;
  while (low <= high) {
    long long int mid = (low + high) / 2;
    if (mid % 2 == 0) mid--;
    long long int temp = mid, cnt = 0, mul = 1;
    while (temp <= n) {
      if (n - temp + 1 >= mul)
        cnt += mul;
      else {
        cnt += n - temp + 1;
        break;
      }
      mul = mul * 2;
      temp = temp * 2;
    }
    if (cnt >= k) {
      low = mid + 2;
      ans = max(ans, mid);
    } else
      high = mid - 2;
  }
  low = 2, high = 1e18;
  while (low <= high) {
    long long int mid = (low + high) / 2;
    if (mid % 2 == 1) mid--;
    long long int temp = mid, cnt = 0, mul = 2;
    while (temp <= n) {
      if (n - temp + 1 >= mul)
        cnt += mul;
      else {
        cnt += n - temp + 1;
        break;
      }
      mul = mul * 2;
      temp = temp * 2;
    }
    if (cnt >= k) {
      low = mid + 2;
      ans = max(ans, mid);
    } else
      high = mid - 2;
  }
  cout << ans;
}
