#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, maxn = 100001;
long long C[66][66];
void init(int n = 62) {
  C[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++) C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
  }
}
int main() {
  init();
  long long m;
  int k;
  while (~scanf("%I64d%d", &m, &k)) {
    if (k == 1 || m == 0) {
      printf("1\n");
      continue;
    }
    int n = k;
    while (1) {
      if (C[n - 2][k - 2] >= m) break;
      m -= C[n - 2][k - 2];
      n++;
    }
    long long ans = (1ll << (n - 1)) + 1;
    k -= 2;
    for (int i = n - 2; i && k; i--) {
      if (m > C[i - 1][k]) m -= C[i - 1][k], k--, ans += (1ll << i);
    }
    printf("%I64d\n", (ans + 1) >> 1);
  }
  return 0;
}

### Prompt

Create a solution in Cpp for the following problem:

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;
const int INF = 0x3f3f3f3f, maxn = 100001;
long long C[66][66];
void init(int n = 62) {
  C[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++) C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
  }
}
int main() {
  init();
  long long m;
  int k;
  while (~scanf("%I64d%d", &m, &k)) {
    if (k == 1 || m == 0) {
      printf("1\n");
      continue;
    }
    int n = k;
    while (1) {
      if (C[n - 2][k - 2] >= m) break;
      m -= C[n - 2][k - 2];
      n++;
    }
    long long ans = (1ll << (n - 1)) + 1;
    k -= 2;
    for (int i = n - 2; i && k; i--) {
      if (m > C[i - 1][k]) m -= C[i - 1][k], k--, ans += (1ll << i);
    }
    printf("%I64d\n", (ans + 1) >> 1);
  }
  return 0;
}

```