#include <bits/stdc++.h>
using namespace std;
long long int log2(long long int n) {
  long long int res = 0;
  while (n) n /= 2, res++;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << n << endl;
    return 0;
  }
  long long int uni = 0;
  int bit = log2(n);
  for (long long int i = 0; i < bit; i++) uni += pow(2, i);
  cout << uni << endl;
  return 0;
}
