#include <bits/stdc++.h>
const int MAXN = 1e5;
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int n, k, j = 1;
  cin >> n >> k;
  while (j < n + 1) {
    j *= 2;
  }
  if (k != 1) {
    cout << j - 1;
    return 0;
  }
  cout << n;
  return 0;
}
