#include <bits/stdc++.h>
using namespace std;
long long int m, k;
long long int dp[70][2][70];
long long int getans(long long int num, int pos, int cap, int k) {
  if (k < 0) return 0;
  if (pos == -1) return k == 0;
  long long int &ret = dp[pos][cap][k];
  if (ret == -1) {
    ret = 0;
    int cbit = 0;
    if ((num & (1LL << pos))) {
      cbit = 1;
    }
    if (cbit == 1 || cap) ret += getans(num, pos - 1, cap, k - 1);
    ret += getans(num, pos - 1, (cap || cbit), k);
  }
  return ret;
}
long long int getcnt(long long int num, int k) {
  memset(dp, -1, sizeof(dp));
  long long int tnum = num;
  int pos = 0;
  while (tnum) {
    tnum >>= 1;
    if (tnum != 0) pos++;
  }
  return getans(num, pos, 0, k);
}
void check(long long int n) {
  long long int ans = 0;
  for (long long int i = n + 1; i <= n + n; i++) {
    if (__builtin_popcount(i) == k) ans++;
  }
  assert(ans == m);
}
int main() {
  int i;
  cin >> m >> k;
  long long int lb = 1, ub = 1e18, mid, ans;
  while (lb <= ub) {
    mid = (lb + ub) / 2;
    long long int cnt = getcnt(2 * mid, k) - getcnt(mid, k);
    if (cnt == m) {
      cout << mid << endl;
      return 0;
    } else if (cnt > m) {
      ub = mid - 1;
    } else {
      lb = mid + 1;
    }
  }
  assert(false);
  return 0;
}

### Prompt

Generate 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>
using namespace std;
long long int m, k;
long long int dp[70][2][70];
long long int getans(long long int num, int pos, int cap, int k) {
  if (k < 0) return 0;
  if (pos == -1) return k == 0;
  long long int &ret = dp[pos][cap][k];
  if (ret == -1) {
    ret = 0;
    int cbit = 0;
    if ((num & (1LL << pos))) {
      cbit = 1;
    }
    if (cbit == 1 || cap) ret += getans(num, pos - 1, cap, k - 1);
    ret += getans(num, pos - 1, (cap || cbit), k);
  }
  return ret;
}
long long int getcnt(long long int num, int k) {
  memset(dp, -1, sizeof(dp));
  long long int tnum = num;
  int pos = 0;
  while (tnum) {
    tnum >>= 1;
    if (tnum != 0) pos++;
  }
  return getans(num, pos, 0, k);
}
void check(long long int n) {
  long long int ans = 0;
  for (long long int i = n + 1; i <= n + n; i++) {
    if (__builtin_popcount(i) == k) ans++;
  }
  assert(ans == m);
}
int main() {
  int i;
  cin >> m >> k;
  long long int lb = 1, ub = 1e18, mid, ans;
  while (lb <= ub) {
    mid = (lb + ub) / 2;
    long long int cnt = getcnt(2 * mid, k) - getcnt(mid, k);
    if (cnt == m) {
      cout << mid << endl;
      return 0;
    } else if (cnt > m) {
      ub = mid - 1;
    } else {
      lb = mid + 1;
    }
  }
  assert(false);
  return 0;
}

```