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