#include <bits/stdc++.h>
using namespace std;
int str[66];
long long m;
int k;
long long memo[66][66][3];
int vis[66][66][3], vid = 0;
void setstr(long long v) {
  int idx = 61;
  while (v) {
    str[idx--] = (v & 1);
    v >>= 1;
  }
  while (~idx) {
    str[idx--] = 0;
  }
  ++vid;
}
long long solve(int idx, int k, bool ls) {
  if (idx == 62) {
    if (k == 0) return 1;
    return 0;
  }
  if (k < 0) return 0;
  if (vis[idx][k][ls] == vid) {
    return memo[idx][k][ls];
  }
  long long &res = memo[idx][k][ls];
  res = 0;
  vis[idx][k][ls] = vid;
  if (ls) {
    res += solve(idx + 1, k, ls);
    res += solve(idx + 1, k - 1, ls);
  } else {
    for (int i = 0; i <= str[idx]; ++i) {
      res += solve(idx + 1, k - i, ls | (i < str[idx]));
    }
  }
  return res;
}
int main() {
  scanf("%lld %d", &m, &k);
  long long s = 1, e = 1e18;
  while (s < e) {
    long long mid = s + (e - s) / 2;
    setstr(mid * 2);
    long long v = solve(0, k, 0);
    setstr(mid);
    v -= solve(0, k, 0);
    if (v < m)
      s = mid + 1;
    else
      e = mid;
  }
  printf("%lld\n", s);
}

### 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;
int str[66];
long long m;
int k;
long long memo[66][66][3];
int vis[66][66][3], vid = 0;
void setstr(long long v) {
  int idx = 61;
  while (v) {
    str[idx--] = (v & 1);
    v >>= 1;
  }
  while (~idx) {
    str[idx--] = 0;
  }
  ++vid;
}
long long solve(int idx, int k, bool ls) {
  if (idx == 62) {
    if (k == 0) return 1;
    return 0;
  }
  if (k < 0) return 0;
  if (vis[idx][k][ls] == vid) {
    return memo[idx][k][ls];
  }
  long long &res = memo[idx][k][ls];
  res = 0;
  vis[idx][k][ls] = vid;
  if (ls) {
    res += solve(idx + 1, k, ls);
    res += solve(idx + 1, k - 1, ls);
  } else {
    for (int i = 0; i <= str[idx]; ++i) {
      res += solve(idx + 1, k - i, ls | (i < str[idx]));
    }
  }
  return res;
}
int main() {
  scanf("%lld %d", &m, &k);
  long long s = 1, e = 1e18;
  while (s < e) {
    long long mid = s + (e - s) / 2;
    setstr(mid * 2);
    long long v = solve(0, k, 0);
    setstr(mid);
    v -= solve(0, k, 0);
    if (v < m)
      s = mid + 1;
    else
      e = mid;
  }
  printf("%lld\n", s);
}

```