#include <bits/stdc++.h>
using namespace std;
unsigned long long int logg(unsigned long long int);
unsigned long long int cal(unsigned long long int r) {
  unsigned long long int res = 1;
  for (int i = 1; i <= r; i++) res *= 2;
  return res;
}
unsigned long long int logg(unsigned long long int n) {
  int cntl = 0;
  while (n > 0) {
    n /= 2;
    cntl++;
  }
  return cntl;
}
int main(int argc, char const *argv[]) {
  unsigned long long int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << n << endl;
    return 0;
  }
  unsigned long long int r = logg(n);
  cout << cal(r) - 1 << endl;
  return 0;
}
