#include <bits/stdc++.h>
using namespace std;
const long long unsigned int linf = (long long unsigned int)1e18 + 9;
const int inf = 1e9 + 9;
const int N = 1e5 + 9;
vector<long long unsigned int> tab;
long long unsigned int m, k, dp[70][70];
void f(long long unsigned int temp) {
  if (!temp) return;
  f(temp / 2);
  tab.push_back(temp % 2);
}
long long unsigned int coz(long long unsigned int temp) {
  tab.clear();
  f(temp);
  long long unsigned int n = tab.size(), s1 = 0, s11 = 0;
  long long unsigned int ans1 = 0, ans2 = 0;
  for (int i = 0; i < n and s1 <= k; i++) {
    if (tab[i] == 1) {
      ans1 += dp[n - i - 1][k - s1];
      s1++;
    }
  }
  if (s1 == k) ans1++;
  s1 = 0;
  tab.clear();
  f(temp * 2);
  n = tab.size();
  for (int i = 0; i < n and s1 <= k; i++) {
    if (tab[i] == 1) {
      ans2 += dp[n - i - 1][k - s1];
      s1++;
    }
  }
  if (s1 == k) ans2++;
  return ans2 - ans1;
}
int main() {
  cin >> m >> k;
  for (int i = 0; i <= 65; i++) dp[i][0] = dp[i][i] = 1;
  for (int i = 1; i <= 65; i++)
    for (int j = 1; j <= i; j++) dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]);
  long long unsigned int bas = 0;
  long long unsigned int son = linf;
  while (bas + 1 < son) {
    long long unsigned int orta = bas + son >> 1;
    if (coz(orta) < m)
      bas = orta;
    else if (coz(orta) == m) {
      cout << orta << endl;
      return 0;
    } else
      son = orta;
  }
  return 0;
}

### 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;
const long long unsigned int linf = (long long unsigned int)1e18 + 9;
const int inf = 1e9 + 9;
const int N = 1e5 + 9;
vector<long long unsigned int> tab;
long long unsigned int m, k, dp[70][70];
void f(long long unsigned int temp) {
  if (!temp) return;
  f(temp / 2);
  tab.push_back(temp % 2);
}
long long unsigned int coz(long long unsigned int temp) {
  tab.clear();
  f(temp);
  long long unsigned int n = tab.size(), s1 = 0, s11 = 0;
  long long unsigned int ans1 = 0, ans2 = 0;
  for (int i = 0; i < n and s1 <= k; i++) {
    if (tab[i] == 1) {
      ans1 += dp[n - i - 1][k - s1];
      s1++;
    }
  }
  if (s1 == k) ans1++;
  s1 = 0;
  tab.clear();
  f(temp * 2);
  n = tab.size();
  for (int i = 0; i < n and s1 <= k; i++) {
    if (tab[i] == 1) {
      ans2 += dp[n - i - 1][k - s1];
      s1++;
    }
  }
  if (s1 == k) ans2++;
  return ans2 - ans1;
}
int main() {
  cin >> m >> k;
  for (int i = 0; i <= 65; i++) dp[i][0] = dp[i][i] = 1;
  for (int i = 1; i <= 65; i++)
    for (int j = 1; j <= i; j++) dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]);
  long long unsigned int bas = 0;
  long long unsigned int son = linf;
  while (bas + 1 < son) {
    long long unsigned int orta = bas + son >> 1;
    if (coz(orta) < m)
      bas = orta;
    else if (coz(orta) == m) {
      cout << orta << endl;
      return 0;
    } else
      son = orta;
  }
  return 0;
}

```