#include <bits/stdc++.h>
using namespace std;
unsigned long long n, k, ans = 1;
unsigned long long go(unsigned long long i) { return log2(i); }
signed main() {
  cin >> n >> k;
  if (k == 1) {
    cout << n;
    return 0;
  }
  while (n) {
    n >>= 1;
    ans <<= 1;
  }
  cout << ans - 1;
  return 0;
}
