#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, t1, t2, t3, t4, n, k, ans;
  scanf("%lld %lld", &n, &k);
  ans = 0;
  t1 = 1;
  while (t1 <= n) {
    t1 *= 2;
  }
  t1--;
  ans = t1;
  if (k == 1) {
    ans = n;
  }
  printf("%lld\n", ans);
  return 0;
}
