#include <bits/stdc++.h>
using namespace std;
inline char skipwhitespace() {
  char ch = getchar();
  while (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t') ch = getchar();
  return ch;
}
void gi(int &x) {
  register int c = getchar();
  x = 0;
  int sn = 1;
  for (; (c < 48 || c > 57); c = getchar())
    if (c == '-') sn = -1;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  x *= sn;
}
void gii(long long &x) {
  register long long c = getchar();
  x = 0;
  long long sn = 1;
  for (; (c < 48 || c > 57); c = getchar())
    if (c == '-') sn = -1;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  x *= sn;
}
void wi(int n) {
  int sign = n >= 0 ? 1 : -1;
  n = n > 0 ? n : -n;
  char buf[10];
  int i = 9;
  if (!n) buf[i--] = 48;
  while (n) {
    buf[i--] = n % 10 + 48;
    n /= 10;
  }
  if (sign < 0) printf("%c", '-');
  while (++i < 10) printf("%c", buf[i]);
}
void wii(long long n) {
  long long sign = n >= 0 ? 1 : -1;
  n = n > 0 ? n : -n;
  char buf[25];
  long long i = 24;
  if (!n) buf[i--] = 48;
  while (n) {
    buf[i--] = n % 10 + 48;
    n /= 10;
  }
  if (sign < 0) printf("%c", '-');
  while (++i < 25) printf("%c", buf[i]);
}
int gs(char *s) {
  char ch = skipwhitespace();
  int n = 0;
  while ((ch != '\n' && ch != ' ' && ch != '\t')) {
    s[n++] = ch;
    ch = getchar();
  }
  s[n] = 0;
  return n;
}
void ws(char *s) {
  char *p = s;
  while (*p) {
    printf("%c", *p);
    p++;
  }
}
long long NCR[65][65];
long long ncr(long long n, long long r) {
  r = min(n - r, r);
  long long ans = 1;
  for (int i = 1; i <= r; i++) {
    ans *= n;
    ans /= i;
    n--;
  }
  return (r < 0) ? 0 : ans;
}
void cal(long long n, long long *arr) {
  for (int i = 0; i < 65; i++) arr[i] = 0;
  for (int i = 0; i < 65; i++) arr[i] = NCR[n][i];
}
void getchar(long long n, long long *arr) {
  long long temp[65 + 10];
  for (int i = 0; i < 65; i++) arr[i] = 0;
  int cnt = 0;
  for (int i = 63; i >= 0; i--) {
    if (n & (1 * 1ll << i)) {
      if (cnt) {
        cal(i, temp);
        temp[1]++;
        temp[0]--;
        for (int j = 65 - 1; j >= 0; j--) {
          if (j - cnt >= 0)
            temp[j] = temp[j - cnt];
          else
            temp[j] = 0;
        }
        for (int j = 0; j < 65; j++) arr[j] += temp[j];
      } else {
        cal(i, temp);
        temp[1]++;
        for (int j = 0; j < 65; j++) arr[j] += temp[j];
      }
      cnt++;
    }
  }
}
bool f(long long n, long long m, long long k) {
  long long a[65 + 10], b[65 + 10];
  getchar(n, a);
  getchar(2 * n, b);
  for (int i = 0; i < 65; i++) b[i] -= a[i];
  return b[k] >= m;
}
int main() {
  long long n, m, k, l = 0, r = 1e9;
  gii(m);
  gii(k);
  for (int i = 0; i < 65; i++)
    for (int j = 0; j < 65; j++) NCR[i][j] = ncr(i, j);
  l = 0;
  r = r * 1ll * r;
  while (l <= r) {
    n = (l + r) / 2;
    if (f(n, m, k))
      r = n - 1;
    else
      l = n + 1;
  }
  if (r + 1)
    wii(r + 1);
  else
    wii(1);
  printf("\n");
  return 0;
}

### 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>
using namespace std;
inline char skipwhitespace() {
  char ch = getchar();
  while (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t') ch = getchar();
  return ch;
}
void gi(int &x) {
  register int c = getchar();
  x = 0;
  int sn = 1;
  for (; (c < 48 || c > 57); c = getchar())
    if (c == '-') sn = -1;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  x *= sn;
}
void gii(long long &x) {
  register long long c = getchar();
  x = 0;
  long long sn = 1;
  for (; (c < 48 || c > 57); c = getchar())
    if (c == '-') sn = -1;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  x *= sn;
}
void wi(int n) {
  int sign = n >= 0 ? 1 : -1;
  n = n > 0 ? n : -n;
  char buf[10];
  int i = 9;
  if (!n) buf[i--] = 48;
  while (n) {
    buf[i--] = n % 10 + 48;
    n /= 10;
  }
  if (sign < 0) printf("%c", '-');
  while (++i < 10) printf("%c", buf[i]);
}
void wii(long long n) {
  long long sign = n >= 0 ? 1 : -1;
  n = n > 0 ? n : -n;
  char buf[25];
  long long i = 24;
  if (!n) buf[i--] = 48;
  while (n) {
    buf[i--] = n % 10 + 48;
    n /= 10;
  }
  if (sign < 0) printf("%c", '-');
  while (++i < 25) printf("%c", buf[i]);
}
int gs(char *s) {
  char ch = skipwhitespace();
  int n = 0;
  while ((ch != '\n' && ch != ' ' && ch != '\t')) {
    s[n++] = ch;
    ch = getchar();
  }
  s[n] = 0;
  return n;
}
void ws(char *s) {
  char *p = s;
  while (*p) {
    printf("%c", *p);
    p++;
  }
}
long long NCR[65][65];
long long ncr(long long n, long long r) {
  r = min(n - r, r);
  long long ans = 1;
  for (int i = 1; i <= r; i++) {
    ans *= n;
    ans /= i;
    n--;
  }
  return (r < 0) ? 0 : ans;
}
void cal(long long n, long long *arr) {
  for (int i = 0; i < 65; i++) arr[i] = 0;
  for (int i = 0; i < 65; i++) arr[i] = NCR[n][i];
}
void getchar(long long n, long long *arr) {
  long long temp[65 + 10];
  for (int i = 0; i < 65; i++) arr[i] = 0;
  int cnt = 0;
  for (int i = 63; i >= 0; i--) {
    if (n & (1 * 1ll << i)) {
      if (cnt) {
        cal(i, temp);
        temp[1]++;
        temp[0]--;
        for (int j = 65 - 1; j >= 0; j--) {
          if (j - cnt >= 0)
            temp[j] = temp[j - cnt];
          else
            temp[j] = 0;
        }
        for (int j = 0; j < 65; j++) arr[j] += temp[j];
      } else {
        cal(i, temp);
        temp[1]++;
        for (int j = 0; j < 65; j++) arr[j] += temp[j];
      }
      cnt++;
    }
  }
}
bool f(long long n, long long m, long long k) {
  long long a[65 + 10], b[65 + 10];
  getchar(n, a);
  getchar(2 * n, b);
  for (int i = 0; i < 65; i++) b[i] -= a[i];
  return b[k] >= m;
}
int main() {
  long long n, m, k, l = 0, r = 1e9;
  gii(m);
  gii(k);
  for (int i = 0; i < 65; i++)
    for (int j = 0; j < 65; j++) NCR[i][j] = ncr(i, j);
  l = 0;
  r = r * 1ll * r;
  while (l <= r) {
    n = (l + r) / 2;
    if (f(n, m, k))
      r = n - 1;
    else
      l = n + 1;
  }
  if (r + 1)
    wii(r + 1);
  else
    wii(1);
  printf("\n");
  return 0;
}

```