#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, sum = 0, count = 0, m, flag = 1, ans = 0, k;
  cin >> n >> k;
  if (k == 1) {
    cout << n;
    return 0;
  }
  vector<long long int> v, c, d;
  m = n;
  while (m) {
    ans += flag;
    flag = flag * 2;
    m /= 2;
  }
  cout << ans;
  return 0;
}
