#include <bits/stdc++.h>
using namespace std;
string lim;
long long m, k, dp[70][70][2];
long long solve(int ind, int lft, int f) {
  if (dp[ind][lft][f] != -1) return dp[ind][lft][f];
  if (ind == lim.size()) return lft == 0;
  long long ret = 0;
  if (lft && (f || lim[ind] == '1')) {
    ret += solve(ind + 1, lft - 1, f);
  }
  ret += solve(ind + 1, lft, f || lim[ind] == '1');
  return dp[ind][lft][f] = ret;
}
int main() {
  scanf("%lld %lld", &m, &k);
  long long ini = 1, fim = 1000000000000000000LL;
  while (ini <= fim) {
    long long meio = (ini + fim) / 2;
    memset(dp, -1, sizeof dp);
    lim = "";
    long long aux = 2 * meio;
    while (aux) {
      lim += (aux & 1) + '0';
      aux /= 2;
    }
    reverse(lim.begin(), lim.end());
    long long quant = solve(0, k, 0);
    memset(dp, -1, sizeof dp);
    lim = "";
    aux = meio;
    while (aux) {
      lim += (aux & 1) + '0';
      aux /= 2;
    }
    reverse(lim.begin(), lim.end());
    quant -= solve(0, k, 0);
    if (quant < m)
      ini = meio + 1;
    else
      fim = meio - 1;
  }
  printf("%lld\n", ini);
  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;
string lim;
long long m, k, dp[70][70][2];
long long solve(int ind, int lft, int f) {
  if (dp[ind][lft][f] != -1) return dp[ind][lft][f];
  if (ind == lim.size()) return lft == 0;
  long long ret = 0;
  if (lft && (f || lim[ind] == '1')) {
    ret += solve(ind + 1, lft - 1, f);
  }
  ret += solve(ind + 1, lft, f || lim[ind] == '1');
  return dp[ind][lft][f] = ret;
}
int main() {
  scanf("%lld %lld", &m, &k);
  long long ini = 1, fim = 1000000000000000000LL;
  while (ini <= fim) {
    long long meio = (ini + fim) / 2;
    memset(dp, -1, sizeof dp);
    lim = "";
    long long aux = 2 * meio;
    while (aux) {
      lim += (aux & 1) + '0';
      aux /= 2;
    }
    reverse(lim.begin(), lim.end());
    long long quant = solve(0, k, 0);
    memset(dp, -1, sizeof dp);
    lim = "";
    aux = meio;
    while (aux) {
      lim += (aux & 1) + '0';
      aux /= 2;
    }
    reverse(lim.begin(), lim.end());
    quant -= solve(0, k, 0);
    if (quant < m)
      ini = meio + 1;
    else
      fim = meio - 1;
  }
  printf("%lld\n", ini);
  return 0;
}

```