#include <bits/stdc++.h>
using namespace std;
unsigned long long m;
int k;
int second[65];
unsigned long long dp[65][2][69];
unsigned long long cal(unsigned long long n) {
  unsigned long long t = -1;
  if (n == t) return 0;
  for (int i = 0; i < 64; i++) second[i] = n & 1, n >>= 1;
  memset(dp, 0, sizeof(dp));
  dp[64][0][0] = 1;
  for (int i = 64; i > 0; i--)
    for (int j = 0; j <= k; j++) {
      if (dp[i][0][j]) {
        if (second[i - 1]) {
          dp[i - 1][0][j + 1] += dp[i][0][j];
          dp[i - 1][1][j] += dp[i][0][j];
        } else
          dp[i - 1][0][j] += dp[i][0][j];
      }
      if (dp[i][1][j]) {
        dp[i - 1][1][j] += dp[i][1][j];
        dp[i - 1][1][j + 1] += dp[i][1][j];
      }
    }
  return dp[0][0][k] + dp[0][1][k];
}
unsigned long long sol() {
  unsigned long long l = 0, r = (unsigned long long)1e18 + 5, mid;
  ;
  while (l <= r) {
    mid = (l + r) >> 1;
    unsigned long long v = cal(mid << 1) - cal(mid);
    if (v == m)
      return mid;
    else if (v > m)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return r;
}
int main() {
  cin >> m >> k;
  if (m == 0) return puts("1"), 0;
  cout << sol() << endl;
  return 0;
}

### Prompt

Please provide a cpp coded solution 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>
using namespace std;
unsigned long long m;
int k;
int second[65];
unsigned long long dp[65][2][69];
unsigned long long cal(unsigned long long n) {
  unsigned long long t = -1;
  if (n == t) return 0;
  for (int i = 0; i < 64; i++) second[i] = n & 1, n >>= 1;
  memset(dp, 0, sizeof(dp));
  dp[64][0][0] = 1;
  for (int i = 64; i > 0; i--)
    for (int j = 0; j <= k; j++) {
      if (dp[i][0][j]) {
        if (second[i - 1]) {
          dp[i - 1][0][j + 1] += dp[i][0][j];
          dp[i - 1][1][j] += dp[i][0][j];
        } else
          dp[i - 1][0][j] += dp[i][0][j];
      }
      if (dp[i][1][j]) {
        dp[i - 1][1][j] += dp[i][1][j];
        dp[i - 1][1][j + 1] += dp[i][1][j];
      }
    }
  return dp[0][0][k] + dp[0][1][k];
}
unsigned long long sol() {
  unsigned long long l = 0, r = (unsigned long long)1e18 + 5, mid;
  ;
  while (l <= r) {
    mid = (l + r) >> 1;
    unsigned long long v = cal(mid << 1) - cal(mid);
    if (v == m)
      return mid;
    else if (v > m)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return r;
}
int main() {
  cin >> m >> k;
  if (m == 0) return puts("1"), 0;
  cout << sol() << endl;
  return 0;
}

```