#include <bits/stdc++.h>
using namespace std;
long long seq, limit, ans = 0;
vector<long long> xo;
long long xorSum() {
  while (seq != 0) {
    seq /= 2;
    ans++;
  }
  return pow(2, ans) - 1;
}
int main() {
  ios_base ::sync_with_stdio(false);
  bool f = 1;
  cin >> seq >> limit;
  if (limit == 1) {
    cout << seq;
    f = 0;
  }
  if (f) cout << xorSum() << endl;
}
