#include <bits/stdc++.h>
using namespace std;
long long m, k;
vector<int> a;
int n;
long long f[65][65][2];
long long cal(int id, long long X, int k, bool small) {
  if (k < 0) return 0;
  if (id < 0) return (k == 0);
  long long &res = f[id][k][small];
  if (res > -1) return res;
  res = 0;
  for (int i = (0); i <= ((((X >> id) & 1LL) | small)); ++i) {
    res += cal(id - 1, X, k - i, (i < ((X >> id) & 1LL)) | small);
  }
  return res;
}
long long get(long long X, int k) {
  a.clear();
  n = a.size() - 1;
  memset(f, -1, sizeof f);
  return cal(62, X, k, 0);
}
int main() {
  cin >> m >> k;
  long long low = 1;
  long long high = 1000000000000000000LL;
  long long res = 0;
  while (high >= low) {
    long long mid = (high + low) / 2;
    long long x = get(mid, k);
    long long y = get(2 * mid, k);
    long long dx = y - x;
    if (dx == m) {
      res = mid;
      break;
    } else if (dx < m)
      low = mid + 1;
    else
      high = mid - 1;
  }
  cout << res << endl;
}

### Prompt

Develop a solution in CPP 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;
long long m, k;
vector<int> a;
int n;
long long f[65][65][2];
long long cal(int id, long long X, int k, bool small) {
  if (k < 0) return 0;
  if (id < 0) return (k == 0);
  long long &res = f[id][k][small];
  if (res > -1) return res;
  res = 0;
  for (int i = (0); i <= ((((X >> id) & 1LL) | small)); ++i) {
    res += cal(id - 1, X, k - i, (i < ((X >> id) & 1LL)) | small);
  }
  return res;
}
long long get(long long X, int k) {
  a.clear();
  n = a.size() - 1;
  memset(f, -1, sizeof f);
  return cal(62, X, k, 0);
}
int main() {
  cin >> m >> k;
  long long low = 1;
  long long high = 1000000000000000000LL;
  long long res = 0;
  while (high >= low) {
    long long mid = (high + low) / 2;
    long long x = get(mid, k);
    long long y = get(2 * mid, k);
    long long dx = y - x;
    if (dx == m) {
      res = mid;
      break;
    } else if (dx < m)
      low = mid + 1;
    else
      high = mid - 1;
  }
  cout << res << endl;
}

```