#include <bits/stdc++.h>
using namespace std;
const long long MX = (long long)2e18 + 1;
const long long LIM = (long long)2e18 + 1;
long long c[70][70];
void init() {
  c[0][0] = 1;
  for (long long i = 1; i <= 64; i++) {
    c[i][0] = 1;
    for (long long j = 1; j <= i; j++) {
      c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
    }
  }
}
long long get_cnk(long long n, long long k) {
  if (n < 0 || k < 0) {
    return 0;
  }
  return c[n][k];
}
long long count_pref(long long k, long long ones) {
  long long len = sizeof(k) * 8;
  long long p = 1ll << (len - 2);
  long long was = 0;
  long long res = 0;
  for (long long i = 0; i < len; i++, p >>= 1) {
    if (k & p) {
      long long t = len - i - 2;
      res += get_cnk(t, ones - was);
      was++;
    }
  }
  return res;
}
long long calc(long long m, long long ones) {
  return count_pref(2 * m + 1, ones) - count_pref(m + 1, ones);
}
int main() {
  init();
  long long m, k;
  cin >> m >> k;
  long long l = 0, r = MX;
  while (r - l > 1) {
    long long n = (l + r) / 2;
    if (calc(n, k) < m) {
      l = n;
    } else {
      r = n;
    }
  }
  cout << r << endl;
  return 0;
}

### Prompt

Please create a solution in Cpp to 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;
const long long MX = (long long)2e18 + 1;
const long long LIM = (long long)2e18 + 1;
long long c[70][70];
void init() {
  c[0][0] = 1;
  for (long long i = 1; i <= 64; i++) {
    c[i][0] = 1;
    for (long long j = 1; j <= i; j++) {
      c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
    }
  }
}
long long get_cnk(long long n, long long k) {
  if (n < 0 || k < 0) {
    return 0;
  }
  return c[n][k];
}
long long count_pref(long long k, long long ones) {
  long long len = sizeof(k) * 8;
  long long p = 1ll << (len - 2);
  long long was = 0;
  long long res = 0;
  for (long long i = 0; i < len; i++, p >>= 1) {
    if (k & p) {
      long long t = len - i - 2;
      res += get_cnk(t, ones - was);
      was++;
    }
  }
  return res;
}
long long calc(long long m, long long ones) {
  return count_pref(2 * m + 1, ones) - count_pref(m + 1, ones);
}
int main() {
  init();
  long long m, k;
  cin >> m >> k;
  long long l = 0, r = MX;
  while (r - l > 1) {
    long long n = (l + r) / 2;
    if (calc(n, k) < m) {
      l = n;
    } else {
      r = n;
    }
  }
  cout << r << endl;
  return 0;
}

```