#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:10000000000000")
using namespace std;
const int inf((1 << 31) - 1);
int dx[] = {0, 0, -1, 1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int MaxN = 200000 + 10;
const int MaxST = 4 * MaxN;
int cnt(unsigned long long a) {
  int out = 0;
  while (a > 0) {
    out += a & 1;
    a >>= 1;
  }
  return out;
}
unordered_map<unsigned long long, unsigned long long> hshmp[70];
unsigned long long rec(unsigned long long n, int k) {
  if (k == 0) return 0ull;
  if (n == 0ull) {
    return 0ull;
  }
  if (n == 1ull) {
    if (k == 1) return 1ull;
    return 0ull;
  }
  if (hshmp[k].count(n)) {
    return hshmp[k][n];
  }
  unsigned long long out = rec(n / 2, k) + rec(n / 2, k - 1);
  if (n & 1) {
    out += (cnt(n) == k);
  }
  hshmp[k][n] = out;
  return out;
}
unsigned long long check(unsigned long long n, unsigned long long k) {
  unsigned long long out = 0;
  for (unsigned long long i = n + 1; i <= 2 * n; i++) {
    if (cnt(i) == k) {
      out++;
    }
  }
  return out;
}
int main() {
  ios_base::sync_with_stdio(0);
  unsigned long long m, k;
  cin >> m >> k;
  unsigned long long L = 0, M, R = 1000000000000000000, T;
  while (L < R) {
    M = (L >> 1) + (R >> 1) + (L & R & 1);
    T = rec(M, k);
    if (T == m) {
      cout << M << endl;
      return 0;
    } else if (T > m) {
      R = M;
    } else {
      L = M;
    }
  }
  return 0;
}

### Prompt

Your challenge is to write a cpp solution 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>
#pragma comment(linker, "/STACK:10000000000000")
using namespace std;
const int inf((1 << 31) - 1);
int dx[] = {0, 0, -1, 1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int MaxN = 200000 + 10;
const int MaxST = 4 * MaxN;
int cnt(unsigned long long a) {
  int out = 0;
  while (a > 0) {
    out += a & 1;
    a >>= 1;
  }
  return out;
}
unordered_map<unsigned long long, unsigned long long> hshmp[70];
unsigned long long rec(unsigned long long n, int k) {
  if (k == 0) return 0ull;
  if (n == 0ull) {
    return 0ull;
  }
  if (n == 1ull) {
    if (k == 1) return 1ull;
    return 0ull;
  }
  if (hshmp[k].count(n)) {
    return hshmp[k][n];
  }
  unsigned long long out = rec(n / 2, k) + rec(n / 2, k - 1);
  if (n & 1) {
    out += (cnt(n) == k);
  }
  hshmp[k][n] = out;
  return out;
}
unsigned long long check(unsigned long long n, unsigned long long k) {
  unsigned long long out = 0;
  for (unsigned long long i = n + 1; i <= 2 * n; i++) {
    if (cnt(i) == k) {
      out++;
    }
  }
  return out;
}
int main() {
  ios_base::sync_with_stdio(0);
  unsigned long long m, k;
  cin >> m >> k;
  unsigned long long L = 0, M, R = 1000000000000000000, T;
  while (L < R) {
    M = (L >> 1) + (R >> 1) + (L & R & 1);
    T = rec(M, k);
    if (T == m) {
      cout << M << endl;
      return 0;
    } else if (T > m) {
      R = M;
    } else {
      L = M;
    }
  }
  return 0;
}

```