#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, a, b, ts, f = 1, cn = 0;
  long long n, k, x = 0, p;
  scanf("%lld %lld", &n, &k);
  for (i = 62; i >= 0; i--) {
    if ((n & 1LL << i)) break;
  }
  if (k == 1)
    x = n;
  else
    for (; i >= 0; i--) {
      x = (x | 1LL << i);
    }
  printf("%lld\n", x);
  return 0;
}
