#include <bits/stdc++.h>
using namespace std;
const int N = 66;
const long long bit = 1;
long long k;
long long c[N][N];
void init() {
  memset(c, 0, sizeof(c));
  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] + c[i - 1][j - 1];
  }
}
long long sum(long long x) {
  int cont = 0;
  long long res = 0;
  for (int i = 62; i >= 0; i--) {
    if (x & (bit << i)) {
      if (k - cont >= 0) res += c[i][k - cont];
      cont++;
    }
  }
  return res;
}
long long calc(long long n) {
  long long nn = 2 * n;
  return sum(2 * n) - sum(n);
}
int main() {
  long long m;
  init();
  while (cin >> m >> k) {
    long long l = 1;
    long long r = bit << 62;
    long long ans = 0;
    while (l <= r) {
      long long mid = (l + r) >> 1;
      long long res = calc(mid);
      if (res >= m) {
        ans = mid;
        r = mid - 1;
      } else
        l = mid + 1;
    }
    cout << ans << endl;
  }
  return 0;
}

### Prompt

Construct a CPP code solution to the problem outlined:

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 N = 66;
const long long bit = 1;
long long k;
long long c[N][N];
void init() {
  memset(c, 0, sizeof(c));
  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] + c[i - 1][j - 1];
  }
}
long long sum(long long x) {
  int cont = 0;
  long long res = 0;
  for (int i = 62; i >= 0; i--) {
    if (x & (bit << i)) {
      if (k - cont >= 0) res += c[i][k - cont];
      cont++;
    }
  }
  return res;
}
long long calc(long long n) {
  long long nn = 2 * n;
  return sum(2 * n) - sum(n);
}
int main() {
  long long m;
  init();
  while (cin >> m >> k) {
    long long l = 1;
    long long r = bit << 62;
    long long ans = 0;
    while (l <= r) {
      long long mid = (l + r) >> 1;
      long long res = calc(mid);
      if (res >= m) {
        ans = mid;
        r = mid - 1;
      } else
        l = mid + 1;
    }
    cout << ans << endl;
  }
  return 0;
}

```