#include <bits/stdc++.h>
using namespace ::std;
const long double PI = acos(-1);
const long long MOD = 1000000000 + 7;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long add(long long a, long long b, long long m = MOD) {
  if (a >= m) a %= m;
  if (b >= m) b %= m;
  if (a < 0) a += m;
  if (b < 0) b += m;
  long long res = a + b;
  if (res >= m or res <= -m) res %= m;
  if (res < 0) res += m;
  return res;
}
long long mul(long long a, long long b, long long m = MOD) {
  if (a >= m) a %= m;
  if (b >= m) b %= m;
  if (a < 0) a += m;
  if (b < 0) b += m;
  long long res = a * b;
  if (res >= m or res <= -m) res %= m;
  if (res < 0) res += m;
  return res;
}
long long pow_mod(long long a, long long b, long long m = MOD) {
  long long res = 1LL;
  a = a % m;
  while (b) {
    if (b & 1) res = mul(res, a, m);
    b >>= 1;
    a = mul(a, a, m);
  }
  return res;
}
long long fastexp(long long a, long long b) {
  long long res = 1LL;
  while (b) {
    if (b & 1) res = res * a;
    b >>= 1;
    a *= a;
  }
  return res;
}
int gcdExtendido(int a, int b, int *x, int *y) {
  if (a == 0) {
    *x = 0;
    *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtendido(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
int modInverso(int a, int m) {
  int x, y;
  int g = gcdExtendido(a, m, &x, &y);
  if (g != 1)
    return -1;
  else
    return (x % m + m) % m;
}
const int N = 70;
long long m;
int k;
int len;
vector<int> v;
bool vis[N][N][3];
long long memo[N][N][3];
long long DP(int pos, int ones, bool menor) {
  if (pos == len) return ones == k;
  if (vis[pos][ones][menor]) return memo[pos][ones][menor];
  long long ans = 0LL;
  int limit;
  if (menor)
    limit = 1;
  else
    limit = v[pos];
  for (int i = 0; i <= limit; i++) {
    ans += DP(pos + 1, ones + i, menor or (i < v[pos]));
  }
  vis[pos][ones][menor] = true;
  return memo[pos][ones][menor] = ans;
}
long long f(long long x) {
  v.clear();
  while (x > 0) {
    v.emplace_back(x & 1);
    x >>= 1;
  }
  reverse((v).begin(), (v).end());
  len = v.size();
  memset(vis, 0, sizeof vis);
  return DP(0, 0, 0);
}
int main() {
  scanf("%lld", &(m));
  scanf("%d", &(k));
  long long lo = 1, hi = 1e18;
  while (lo < hi) {
    long long mi = lo + (hi - lo) / 2;
    if (f(2LL * mi) - f(mi) < m)
      lo = mi + 1;
    else
      hi = mi;
  }
  cout << lo << endl;
  return 0;
}

### Prompt

Please create a solution in CPP 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;
const long double PI = acos(-1);
const long long MOD = 1000000000 + 7;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long add(long long a, long long b, long long m = MOD) {
  if (a >= m) a %= m;
  if (b >= m) b %= m;
  if (a < 0) a += m;
  if (b < 0) b += m;
  long long res = a + b;
  if (res >= m or res <= -m) res %= m;
  if (res < 0) res += m;
  return res;
}
long long mul(long long a, long long b, long long m = MOD) {
  if (a >= m) a %= m;
  if (b >= m) b %= m;
  if (a < 0) a += m;
  if (b < 0) b += m;
  long long res = a * b;
  if (res >= m or res <= -m) res %= m;
  if (res < 0) res += m;
  return res;
}
long long pow_mod(long long a, long long b, long long m = MOD) {
  long long res = 1LL;
  a = a % m;
  while (b) {
    if (b & 1) res = mul(res, a, m);
    b >>= 1;
    a = mul(a, a, m);
  }
  return res;
}
long long fastexp(long long a, long long b) {
  long long res = 1LL;
  while (b) {
    if (b & 1) res = res * a;
    b >>= 1;
    a *= a;
  }
  return res;
}
int gcdExtendido(int a, int b, int *x, int *y) {
  if (a == 0) {
    *x = 0;
    *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtendido(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
int modInverso(int a, int m) {
  int x, y;
  int g = gcdExtendido(a, m, &x, &y);
  if (g != 1)
    return -1;
  else
    return (x % m + m) % m;
}
const int N = 70;
long long m;
int k;
int len;
vector<int> v;
bool vis[N][N][3];
long long memo[N][N][3];
long long DP(int pos, int ones, bool menor) {
  if (pos == len) return ones == k;
  if (vis[pos][ones][menor]) return memo[pos][ones][menor];
  long long ans = 0LL;
  int limit;
  if (menor)
    limit = 1;
  else
    limit = v[pos];
  for (int i = 0; i <= limit; i++) {
    ans += DP(pos + 1, ones + i, menor or (i < v[pos]));
  }
  vis[pos][ones][menor] = true;
  return memo[pos][ones][menor] = ans;
}
long long f(long long x) {
  v.clear();
  while (x > 0) {
    v.emplace_back(x & 1);
    x >>= 1;
  }
  reverse((v).begin(), (v).end());
  len = v.size();
  memset(vis, 0, sizeof vis);
  return DP(0, 0, 0);
}
int main() {
  scanf("%lld", &(m));
  scanf("%d", &(k));
  long long lo = 1, hi = 1e18;
  while (lo < hi) {
    long long mi = lo + (hi - lo) / 2;
    if (f(2LL * mi) - f(mi) < m)
      lo = mi + 1;
    else
      hi = mi;
  }
  cout << lo << endl;
  return 0;
}

```