#include <bits/stdc++.h>
using namespace std;
int main() {
  long long m, n;
  while (cin >> m >> n) {
    if (n == 1)
      printf("%lld", m);
    else {
      long long t = 0, sum = 1;
      while (!t) {
        sum *= 2;
        if (sum > m) t = 1;
      }
      printf("%lld\n", sum - 1);
    }
  }
}
