#include <bits/stdc++.h>
using namespace std;
unsigned long long b[62];
int main() {
  b[0] = 1;
  for (int i = 1; i < 62; i++) b[i] = 2 * b[i - 1];
  unsigned long long n, k;
  cin >> n >> k;
  if (k == 1) return cout << n, 0;
  for (int i = 0; i < 61; i++) {
    if (n >= b[i] && n < b[i + 1]) return cout << b[i + 1] - 1 << ' ', 0;
  }
  cout << b[61] - 1;
  return 0;
}
