#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << n;
    return 0;
  }
  long long ans = 0;
  long long x = 1;
  while (x - 1 < n) {
    ans += x;
    x *= 2;
  }
  cout << x - 1;
}
