#include <bits/stdc++.h>
using namespace std;
const int M = log2(2005);
int main() {
  long long n, k, i;
  scanf("%lld%lld", &n, &k);
  if (k == 1) {
    printf("%lld\n", n);
    return 0;
  }
  for (i = 0; (1LL << i) <= n; i++)
    ;
  printf("%lld\n", (1LL << i) - 1LL);
}
