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