#include <bits/stdc++.h>
using namespace std;
const int imax = INT32_MAX;
const int imin = INT32_MIN;
const int mx = 1e9;
const long long int inf = 1e18;
long long int sn(long long int n) { return (n * 1ll * (n - 1)) / 2; }
template <class T>
void print(vector<T> vec) {
  for (T i : vec) cout << i << " ";
  cout << "\n";
}
template <class T>
void alloc(vector<vector<T>*> vec, T n) {
  for (auto v : vec) v->resize(n + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long int t = 1;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    if (k == 1) {
      cout << n;
      continue;
    }
    long long int ans = 1;
    while (ans < n) {
      ans = ans * 1ll * 2 + 1;
    }
    cout << ans;
  }
  return 0;
}
