#include <bits/stdc++.h>
using namespace std;
long long n, k;
int log2(long long x) {
  int ret = 0;
  while (x > 0) {
    x /= 2;
    ret++;
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  clock_t ck;
  ck = clock();
  cin >> n >> k;
  if (k == 1) {
    cout << n << '\n';
    return 0;
  }
  int exp = log2(n);
  cout << (1ll << exp) - 1 << '\n';
  ck = clock() - ck;
  cerr << "It took " << 1.0 * ck / CLOCKS_PER_SEC << " sec\n";
  return 0;
}
