#include <bits/stdc++.h>
inline long long sbt(long long x) { return __builtin_popcount(x); }
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long dp[113][113];
void preprocess() {
  for (long long i = 0; i < 65; i++) {
    for (long long j = 0; j <= min(i, j); j++) {
      if (!j) {
        dp[i][j] = 1;
      } else if (i == j) {
        dp[i][j] = 1;
      } else {
        dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
      }
    }
  }
}
long long ncr(long long n, long long r) { return dp[n][r]; }
long long f(long long n, long long k) {
  if (k <= 0) return 0;
  long long bit = 0;
  for (long long i = 63; i >= 0; i--) {
    if ((n & (1ll << i))) {
      bit = i;
      break;
    }
  }
  if (bit < (k - 1)) return 0;
  return ncr(bit, k) + f(n & ((1LL << bit) - 1), k - 1);
}
int32_t main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  preprocess();
  long long m, k;
  cin >> m >> k;
  long long lo = 1;
  long long hi = 1e18;
  while (lo <= hi) {
    long long mid = (lo + (hi - lo) / 2);
    long long res = (f(2 * mid, k) - f(mid, k));
    if (res == m) {
      cout << mid;
      return 0;
    } else if (res < m) {
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  return 0;
}

### Prompt

Develop a solution in CPP to the problem described below:

One day, after a difficult lecture a diligent student Sasha saw a graffitied desk in the classroom. She came closer and read: "Find such positive integer n, that among numbers n + 1, n + 2, ..., 2·n there are exactly m numbers which binary representation contains exactly k digits one".

The girl got interested in the task and she asked you to help her solve it. Sasha knows that you are afraid of large numbers, so she guaranteed that there is an answer that doesn't exceed 1018.

Input

The first line contains two space-separated integers, m and k (0 ≤ m ≤ 1018; 1 ≤ k ≤ 64).

Output

Print the required number n (1 ≤ n ≤ 1018). If there are multiple answers, print any of them.

Examples

Input

1 1


Output

1


Input

3 2


Output

5

### Response

```cpp
#include <bits/stdc++.h>
inline long long sbt(long long x) { return __builtin_popcount(x); }
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long dp[113][113];
void preprocess() {
  for (long long i = 0; i < 65; i++) {
    for (long long j = 0; j <= min(i, j); j++) {
      if (!j) {
        dp[i][j] = 1;
      } else if (i == j) {
        dp[i][j] = 1;
      } else {
        dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
      }
    }
  }
}
long long ncr(long long n, long long r) { return dp[n][r]; }
long long f(long long n, long long k) {
  if (k <= 0) return 0;
  long long bit = 0;
  for (long long i = 63; i >= 0; i--) {
    if ((n & (1ll << i))) {
      bit = i;
      break;
    }
  }
  if (bit < (k - 1)) return 0;
  return ncr(bit, k) + f(n & ((1LL << bit) - 1), k - 1);
}
int32_t main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  preprocess();
  long long m, k;
  cin >> m >> k;
  long long lo = 1;
  long long hi = 1e18;
  while (lo <= hi) {
    long long mid = (lo + (hi - lo) / 2);
    long long res = (f(2 * mid, k) - f(mid, k));
    if (res == m) {
      cout << mid;
      return 0;
    } else if (res < m) {
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  return 0;
}

```