#include <bits/stdc++.h>
using namespace std;
int toInt(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int main() {
  unsigned long long n, k;
  cin >> n >> k;
  if (k == 1 || n == 1)
    cout << n << endl;
  else {
    long long ex = 0;
    while (n != 1) {
      n /= 2;
      ex++;
    }
    ex++;
    long long ans = (1LL << ex);
    ans -= 1;
    cout << ans << endl;
  }
  return 0;
}
