#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double C = 0.57721566490153286060651209;
const double pi = acos(-1.0);
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
long long qpow(long long x, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans = ans * x;
    x = x * x;
    n >>= 1;
  }
  return ans;
}
int main() {
  long long n, k;
  cin >> n >> k;
  int num = 0;
  if (k == 1) {
    cout << n << endl;
    return 0;
  }
  while (n) {
    n /= 2;
    num++;
  }
  cout << qpow(2, num) - 1 << endl;
  return 0;
}
