#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n = 0, k = 0, t1 = 0, t2 = 0, i = 0, flag = 0;
  cin >> n >> k;
  for (i = 0; i < 1e6; i++) {
    t1 = pow(2, i);
    if (n < t1 && k > 1) {
      t2 = pow(2, i);
      flag = t2 - 1;
      break;
    }
    if (k == 1) {
      flag = n;
    }
  }
  cout << flag;
}
