#include <bits/stdc++.h>
long long int m;
int k1;
long long int c[100][100];
int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
void compute(int n, int k) {
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= min(i, k); j++) {
      if (j == 0 || j == i)
        c[i][j] = 1;
      else
        c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
    }
  }
}
int k;
int temp[500];
void binary_rep(long long int x) {
  k = 0;
  while (x > 0) {
    temp[k++] = (x % 2);
    x /= 2;
  }
  k--;
}
long long int find(long long int x) {
  int left_bit;
  int neededones;
  int cnt = 0;
  long long int ans = 0;
  for (int i = 62; i >= 0; i--) {
    if (x & (1LL << i)) {
      left_bit = i;
      neededones = (k1 - cnt);
      if (neededones >= 0) {
        ans += c[left_bit][neededones];
      }
      cnt++;
    }
  }
  return ans;
}
long long int check(long long int x) { return find(2 * x) - find(x); }
long long int bs(long long int lo, long long int hi) {
  long long int ans = 0;
  while (lo <= hi) {
    long long int mid = (hi + lo) / 2;
    if (check(mid) > m) {
      hi = mid - 1;
    } else if (check(mid) < m) {
      lo = mid + 1;
    } else if (check(mid) == m) {
      lo = mid + 1;
      ans = mid;
    }
  }
  return ans;
}
int main() {
  scanf("%lld %d", &m, &k1);
  compute(65, 65);
  long long int ans = bs(1, (long long int)1e18);
  printf("%lld", ans);
}

### Prompt

In CPP, your task is to solve 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 int m;
int k1;
long long int c[100][100];
int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
void compute(int n, int k) {
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= min(i, k); j++) {
      if (j == 0 || j == i)
        c[i][j] = 1;
      else
        c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
    }
  }
}
int k;
int temp[500];
void binary_rep(long long int x) {
  k = 0;
  while (x > 0) {
    temp[k++] = (x % 2);
    x /= 2;
  }
  k--;
}
long long int find(long long int x) {
  int left_bit;
  int neededones;
  int cnt = 0;
  long long int ans = 0;
  for (int i = 62; i >= 0; i--) {
    if (x & (1LL << i)) {
      left_bit = i;
      neededones = (k1 - cnt);
      if (neededones >= 0) {
        ans += c[left_bit][neededones];
      }
      cnt++;
    }
  }
  return ans;
}
long long int check(long long int x) { return find(2 * x) - find(x); }
long long int bs(long long int lo, long long int hi) {
  long long int ans = 0;
  while (lo <= hi) {
    long long int mid = (hi + lo) / 2;
    if (check(mid) > m) {
      hi = mid - 1;
    } else if (check(mid) < m) {
      lo = mid + 1;
    } else if (check(mid) == m) {
      lo = mid + 1;
      ans = mid;
    }
  }
  return ans;
}
int main() {
  scanf("%lld %d", &m, &k1);
  compute(65, 65);
  long long int ans = bs(1, (long long int)1e18);
  printf("%lld", ans);
}

```