#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << n;
  } else {
    unsigned long long int st = 0;
    unsigned long long int cur = (1 << st) - 1;
    while (cur < n) {
      st++;
      cur = (1ll << st) - 1ll;
    }
    cout << (1ll << st) - 1ll;
  }
  return 0;
}
