#include <bits/stdc++.h>
using namespace std;
int up[70];
long long C[70][70];
void init() {
  for (int i = 0; i <= 66; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
      if (C[i][j] > 1e18) C[i][j] = 1e18, C[i][j]++;
    }
  }
}
long long dfs(bool fg, int pos, int len, int need) {
  if (need == 0) return 1;
  if (pos == len + 1) return 0;
  int res = len - pos + 1;
  if (res < need) return 0;
  if (fg) {
    return C[res][need];
  }
  if (up[pos] == 1) {
    long long res = 0;
    res += dfs(1, pos + 1, len, need);
    res += dfs(0, pos + 1, len, need - 1);
    res = min(res, (long long)(1e18) + 1ll);
    return res;
  }
  return dfs(0, pos + 1, len, need);
}
long long check(long long n, long long k) {
  long long mul = 1;
  while (mul * 2 <= n) mul *= 2;
  int len = 0;
  for (; mul; mul /= 2) {
    up[++len] = n / mul;
    n %= mul;
  }
  long long ct_n = dfs(0, 1, len, k);
  up[++len] = 0;
  long long ct_2n = dfs(0, 1, len, k);
  return ct_2n - ct_n;
}
int main() {
  init();
  long long m, k;
  scanf("%lld%lld", &m, &k);
  long long l = 1, r = 1e18;
  if (check(l, k) == m) return 0 * printf("%lld\n", l);
  if (check(r, k) == m) return 0 * printf("%lld\n", r);
  while (r - l > 1) {
    long long mid = l + r >> 1;
    if (check(mid, k) >= m)
      r = mid;
    else
      l = mid;
  }
  printf("%lld\n", r);
}

### Prompt

Create a solution in cpp for 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;
int up[70];
long long C[70][70];
void init() {
  for (int i = 0; i <= 66; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
      if (C[i][j] > 1e18) C[i][j] = 1e18, C[i][j]++;
    }
  }
}
long long dfs(bool fg, int pos, int len, int need) {
  if (need == 0) return 1;
  if (pos == len + 1) return 0;
  int res = len - pos + 1;
  if (res < need) return 0;
  if (fg) {
    return C[res][need];
  }
  if (up[pos] == 1) {
    long long res = 0;
    res += dfs(1, pos + 1, len, need);
    res += dfs(0, pos + 1, len, need - 1);
    res = min(res, (long long)(1e18) + 1ll);
    return res;
  }
  return dfs(0, pos + 1, len, need);
}
long long check(long long n, long long k) {
  long long mul = 1;
  while (mul * 2 <= n) mul *= 2;
  int len = 0;
  for (; mul; mul /= 2) {
    up[++len] = n / mul;
    n %= mul;
  }
  long long ct_n = dfs(0, 1, len, k);
  up[++len] = 0;
  long long ct_2n = dfs(0, 1, len, k);
  return ct_2n - ct_n;
}
int main() {
  init();
  long long m, k;
  scanf("%lld%lld", &m, &k);
  long long l = 1, r = 1e18;
  if (check(l, k) == m) return 0 * printf("%lld\n", l);
  if (check(r, k) == m) return 0 * printf("%lld\n", r);
  while (r - l > 1) {
    long long mid = l + r >> 1;
    if (check(mid, k) >= m)
      r = mid;
    else
      l = mid;
  }
  printf("%lld\n", r);
}

```