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