#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << n << endl;
    return 0;
  }
  unsigned long long int ans = 1;
  while (ans < n) {
    ans = 2 * ans + 1;
  }
  cout << ans;
  return 0;
}
