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