#include <bits/stdc++.h>
long long m;
int k;
int num[100];
long long dp[100][100];
long long dfs(int pos, int sum, bool lim) {
  if (!pos) return (sum == k);
  if (!lim && ~dp[pos][sum]) return dp[pos][sum];
  int up = lim ? num[pos] : 1;
  long long ans = 0;
  for (int i = 0; i <= up; i++)
    if (sum + (i == 1) <= k)
      ans += dfs(pos - 1, sum + (i == 1), lim && (i == up));
  if (!lim) dp[pos][sum] = ans;
  return ans;
}
long long solve(long long x) {
  int len = 0;
  while (x) num[++len] = x & 1, x >>= 1;
  return dfs(len, 0, 1);
}
long long check(long long x) { return solve(x << 1) - solve(x); }
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%lld %d", &m, &k);
  long long l = 1, r = 1e18;
  while (l <= r) {
    long long mid = (l + r) >> 1, ans = check(mid);
    if (ans == m)
      return !printf("%lld", mid);
    else if (ans > m)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return 0;
}

### Prompt

Your task is to create 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>
long long m;
int k;
int num[100];
long long dp[100][100];
long long dfs(int pos, int sum, bool lim) {
  if (!pos) return (sum == k);
  if (!lim && ~dp[pos][sum]) return dp[pos][sum];
  int up = lim ? num[pos] : 1;
  long long ans = 0;
  for (int i = 0; i <= up; i++)
    if (sum + (i == 1) <= k)
      ans += dfs(pos - 1, sum + (i == 1), lim && (i == up));
  if (!lim) dp[pos][sum] = ans;
  return ans;
}
long long solve(long long x) {
  int len = 0;
  while (x) num[++len] = x & 1, x >>= 1;
  return dfs(len, 0, 1);
}
long long check(long long x) { return solve(x << 1) - solve(x); }
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%lld %d", &m, &k);
  long long l = 1, r = 1e18;
  while (l <= r) {
    long long mid = (l + r) >> 1, ans = check(mid);
    if (ans == m)
      return !printf("%lld", mid);
    else if (ans > m)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return 0;
}

```