#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;
const double EPS = 1e-8;
unsigned long long int C[1010][1010];
void make_C() {
  memset(C, 0, (int)sizeof(C));
  for (int i = 0; i < 1010; 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]);
  }
}
unsigned long long int m;
int k;
unsigned long long int count(string s, int k) {
  if (!k) return 0;
  int d = s.size();
  s.erase(s.end() - 1);
  while (s.size() && *(s.end() - 1) == '0') s.erase(s.end() - 1);
  unsigned long long int ans = C[d - 1][k];
  if (s.size()) ans += count(s, k - 1);
  return ans;
}
string tostring(unsigned long long int k) {
  string ret = k ? "" : "0";
  for (; k; k >>= 1) ret.push_back('0' + (k & 1));
  return ret;
}
unsigned long long int search(unsigned long long int m, int k) {
  unsigned long long int l = 0, r = 1000000000000000000ULL;
  while (l < r - 1) {
    unsigned long long int mid = (l + r) / 2;
    unsigned long long int ret =
        count(tostring(mid * 2 + 1), k) - count(tostring(mid), k);
    if (ret == m) return mid;
    if (ret < m)
      l = mid;
    else
      r = mid;
  }
  return 0;
}
int main() {
  make_C();
  while (cin >> m >> k) {
    cout << search(m, k) << endl;
  }
  return 0;
}

### Prompt

Your task is to create a CPP solution to 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 = 1 << 28;
const double EPS = 1e-8;
unsigned long long int C[1010][1010];
void make_C() {
  memset(C, 0, (int)sizeof(C));
  for (int i = 0; i < 1010; 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]);
  }
}
unsigned long long int m;
int k;
unsigned long long int count(string s, int k) {
  if (!k) return 0;
  int d = s.size();
  s.erase(s.end() - 1);
  while (s.size() && *(s.end() - 1) == '0') s.erase(s.end() - 1);
  unsigned long long int ans = C[d - 1][k];
  if (s.size()) ans += count(s, k - 1);
  return ans;
}
string tostring(unsigned long long int k) {
  string ret = k ? "" : "0";
  for (; k; k >>= 1) ret.push_back('0' + (k & 1));
  return ret;
}
unsigned long long int search(unsigned long long int m, int k) {
  unsigned long long int l = 0, r = 1000000000000000000ULL;
  while (l < r - 1) {
    unsigned long long int mid = (l + r) / 2;
    unsigned long long int ret =
        count(tostring(mid * 2 + 1), k) - count(tostring(mid), k);
    if (ret == m) return mid;
    if (ret < m)
      l = mid;
    else
      r = mid;
  }
  return 0;
}
int main() {
  make_C();
  while (cin >> m >> k) {
    cout << search(m, k) << endl;
  }
  return 0;
}

```