#include <bits/stdc++.h>
using namespace std;
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class L, class R, class M>
ostream& operator<<(ostream& os, tuple<L, R, M> P) {
  return os << "(" << get<0>(P) << "," << get<1>(P) << "," << get<2>(P) << ")";
}
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "{ ";
  for (auto v : V) os << v << " ";
  return os << "}";
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long maxn = (long long)1e5 + 5;
const long double EPS = 1e-9;
const long long INF = (long long)1e9 + 10;
const long long mod = (long long)1e9 + 7;
long long n, k;
long long get(long long L, long long R) {
  if (R > n) {
    R = n;
    return (L > n ? 0LL : R - L + 1);
  }
  long long ret = R - L + 1;
  ret += get(2 * L, 2 * R + 1);
  return ret;
}
long long get_paths(long long number) {
  if (number % 2 == 0) {
    return get(number, number + 1);
  } else {
    return get(number, number);
  }
  assert(false);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  long long answer = 0, bits = 61;
  for (long long bit = bits - 1; bit >= 0; bit--) {
    if (get_paths(answer | (1LL << bit)) >= k) {
      answer |= (1LL << bit);
    }
  }
  cout << answer << '\n';
  return 0;
}
