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