#include <bits/stdc++.h>
using namespace std;
unsigned long long n, m;
int k;
unsigned long long dp[64][2][65];
bool dp2[64][2][65];
unsigned long long f(int b, int x, int c) {
  if (b == 64)
    return x == 1 ? 0 : (c == k ? 1 : 0);
  else if (dp2[b][x][c])
    return dp[b][x][c];
  unsigned long long ret = 0;
  int bit = ((n >> b) & 1);
  ret += f(b + 1, bit ? 0 : x, c);
  ret += f(b + 1, bit ? x : 1, c + 1);
  dp2[b][x][c] = true;
  return dp[b][x][c] = ret;
}
unsigned long long solve(unsigned long long val) {
  n = val;
  memset(dp2, false, sizeof(dp2));
  unsigned long long ret1 = f(0, 0, 0);
  n = val << 1;
  memset(dp2, false, sizeof(dp2));
  unsigned long long ret2 = f(0, 0, 0);
  return ret2 - ret1;
}
int main() {
  cin.sync_with_stdio(false);
  cin >> m >> k;
  unsigned long long low = 1;
  unsigned long long high = 1000000000000000000LL;
  solve(1);
  while (high - low > 1) {
    unsigned long long mid = (low + high) / 2;
    if (solve(mid) < m)
      low = mid;
    else
      high = mid;
  }
  unsigned long long res;
  if (solve(low) == m)
    res = low;
  else
    res = high;
  cout << res << endl;
  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;
unsigned long long n, m;
int k;
unsigned long long dp[64][2][65];
bool dp2[64][2][65];
unsigned long long f(int b, int x, int c) {
  if (b == 64)
    return x == 1 ? 0 : (c == k ? 1 : 0);
  else if (dp2[b][x][c])
    return dp[b][x][c];
  unsigned long long ret = 0;
  int bit = ((n >> b) & 1);
  ret += f(b + 1, bit ? 0 : x, c);
  ret += f(b + 1, bit ? x : 1, c + 1);
  dp2[b][x][c] = true;
  return dp[b][x][c] = ret;
}
unsigned long long solve(unsigned long long val) {
  n = val;
  memset(dp2, false, sizeof(dp2));
  unsigned long long ret1 = f(0, 0, 0);
  n = val << 1;
  memset(dp2, false, sizeof(dp2));
  unsigned long long ret2 = f(0, 0, 0);
  return ret2 - ret1;
}
int main() {
  cin.sync_with_stdio(false);
  cin >> m >> k;
  unsigned long long low = 1;
  unsigned long long high = 1000000000000000000LL;
  solve(1);
  while (high - low > 1) {
    unsigned long long mid = (low + high) / 2;
    if (solve(mid) < m)
      low = mid;
    else
      high = mid;
  }
  unsigned long long res;
  if (solve(low) == m)
    res = low;
  else
    res = high;
  cout << res << endl;
  return 0;
}

```