#include <bits/stdc++.h>
using namespace std;
long long ans(long long a) {
  long long ctr = 0;
  while (a > 0) {
    a = a / 2;
    ctr++;
  }
  return ctr;
}
int main() {
  std::ios::sync_with_stdio(false);
  long long a, b;
  cin >> a >> b;
  if (b == 1) {
    cout << a;
    exit(0);
  }
  long long ctr = ans(a);
  unsigned long long sol = 0;
  for (long long i = 0; i < ctr; ++i) {
    sol = sol + (long long)pow(2LL, i);
  }
  cout << sol;
  return 0;
}
