#include <bits/stdc++.h>
using namespace std;
unsigned long long combination(const unsigned long long &a,
                               const unsigned long long &b) {
  unsigned long long result = 1;
  for (int i = 0; i < b; ++i) {
    result *= a - i;
    result /= i + 1;
  }
  return result;
}
inline unsigned long long get(const unsigned long long &a,
                              const unsigned long long &b) {
  return (1ULL << b) - 1 << (a - b);
}
unsigned long long calculate(const unsigned long long &a,
                             const unsigned long long &b,
                             const unsigned long long &curPosition = 63,
                             const unsigned long long &curValue = 0) {
  if (b <= 0) return curValue <= b;
  if (curPosition <= 0 || b > curPosition) return 0;
  if ((curValue | get(curPosition, b)) <= a) {
    return combination(curPosition, b);
  }
  if (curValue > a) {
    return 0;
  }
  unsigned long long result = calculate(a, b - 1, curPosition - 1,
                                        curValue | (1ULL << curPosition - 1)) +
                              calculate(a, b, curPosition - 1, curValue);
  return result;
}
unsigned long long RandomTask(const unsigned long long &a,
                              const unsigned long long &b) {
  if (a == 0) {
    assert(b >= 2);
    return 1;
  }
  if (a == 1) {
    return 1ULL << b - 1;
  }
  unsigned long long L = 0, R = ULLONG_MAX >> 1, M, answer = 0;
  while (L <= R) {
    M = L + R >> 1;
    unsigned long long result = calculate(M << 1, b) - calculate(M, b);
    if (result >= a) {
      answer = M;
      R = M - 1;
    } else {
      L = M + 1;
    }
  }
  return answer;
}
int run() {
  unsigned long long m, k;
  while (cin >> m >> k) cout << RandomTask(m, k) << endl;
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  return run();
}

### 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 combination(const unsigned long long &a,
                               const unsigned long long &b) {
  unsigned long long result = 1;
  for (int i = 0; i < b; ++i) {
    result *= a - i;
    result /= i + 1;
  }
  return result;
}
inline unsigned long long get(const unsigned long long &a,
                              const unsigned long long &b) {
  return (1ULL << b) - 1 << (a - b);
}
unsigned long long calculate(const unsigned long long &a,
                             const unsigned long long &b,
                             const unsigned long long &curPosition = 63,
                             const unsigned long long &curValue = 0) {
  if (b <= 0) return curValue <= b;
  if (curPosition <= 0 || b > curPosition) return 0;
  if ((curValue | get(curPosition, b)) <= a) {
    return combination(curPosition, b);
  }
  if (curValue > a) {
    return 0;
  }
  unsigned long long result = calculate(a, b - 1, curPosition - 1,
                                        curValue | (1ULL << curPosition - 1)) +
                              calculate(a, b, curPosition - 1, curValue);
  return result;
}
unsigned long long RandomTask(const unsigned long long &a,
                              const unsigned long long &b) {
  if (a == 0) {
    assert(b >= 2);
    return 1;
  }
  if (a == 1) {
    return 1ULL << b - 1;
  }
  unsigned long long L = 0, R = ULLONG_MAX >> 1, M, answer = 0;
  while (L <= R) {
    M = L + R >> 1;
    unsigned long long result = calculate(M << 1, b) - calculate(M, b);
    if (result >= a) {
      answer = M;
      R = M - 1;
    } else {
      L = M + 1;
    }
  }
  return answer;
}
int run() {
  unsigned long long m, k;
  while (cin >> m >> k) cout << RandomTask(m, k) << endl;
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  return run();
}

```