#include <bits/stdc++.h>
using namespace std;
long long n, k, value, two;
int main() {
  cin >> n >> k;
  if (k == 1) {
    cout << n << endl;
  } else {
    value = 0, two = 1;
    int bit = 0;
    while (n) {
      bit++;
      n /= 2;
    }
    for (int i = 0; i < bit; i++) {
      value += (two);
      two *= 2;
    }
    cout << value << endl;
  }
}
