#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 100;
unsigned long long n, k, ans, l;
void init() {
  cin >> n >> k;
  l = 1;
  unsigned long long tmp = 1, Index = 0, cnt = 1;
  while (tmp <= n) {
    tmp *= 2;
    Index++;
  }
  if (k == 1)
    cout << n;
  else
    cout << (l << Index) - 1;
}
int main(int argc, char** argv) {
  init();
  return 0;
}
