#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
namespace IO {
const int L = 1 << 15;
char ibuf[L | 1], *iS = ibuf, *iT = ibuf, obuf[L | 1], *oS = obuf,
                  *oT = obuf + L, c, st[66];
int tp = 0, f;
inline char gc() {
  if (iS == iT) iT = (iS = ibuf) + fread(ibuf, sizeof(char), L, stdin);
  return (*iS++);
}
inline void flush() {
  fwrite(obuf, sizeof(char), oS - obuf, stdout);
  oS = obuf;
}
inline void pc(char c) {
  *oS++ = c;
  if (oS == oT) flush();
}
inline long long read() {
  long long x = 0;
  f = 1, c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c & 15);
  return x * f;
}
inline void write(long long x) {
  if (!x) putchar('0');
  if (x < 0) putchar('-'), x = -x;
  while (x) st[++tp] = x % 10 + '0', x /= 10;
  while (tp) putchar(st[tp--]);
}
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
inline void wri(long long x) { write(x), putchar(' '); }
struct IOflusher {
  ~IOflusher() { flush(); }
} _ioflusher_;
}  // namespace IO
using IO::read;
using IO::wri;
long long k, t, deep;
long long C[20][20], f[20][20];
int a[23], num[20], dep;
long long dp(int x) {
  for (register int i = (0); i <= int(16); ++i) f[0][i] = 1;
  for (register int i = (1); i <= int(x); ++i) {
    for (register int j = (1); j <= int(16); ++j) {
      f[i][j] = 0;
      for (register int k = (0); k <= int(min(i, a[j])); ++k) {
        f[i][j] += f[i - k][j - 1] * C[i][k];
      }
    }
  }
  return f[x][16];
}
void dfs(int k, int x) {
  if (x == 0) return;
  int limitl = (x == dep) ? 2 : 1;
  for (register int i = (limitl); i <= int(16); ++i) {
    if (!a[i]) continue;
    a[i]--;
    long long sz = dp(x - 1);
    if (sz >= k) {
      if (i - 1 >= 10) {
        printf("%c", i - 1 + 'a' - 10);
      } else {
        printf("%d", i - 1);
      }
      dfs(k, x - 1);
      break;
    }
    k -= sz;
    a[i]++;
  }
}
int main() {
  k = read(), t = read();
  for (register int i = (1); i <= int(16); ++i) a[i] = t;
  C[0][0] = 1;
  for (register int i = (1); i <= int(10); ++i) {
    C[i][0] = 1;
    for (register int j = (1); j <= int(i); ++j)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
  }
  dep = 1;
  while (true) {
    a[2]--;
    long long sz = dp(dep - 1) * 15;
    a[2]++;
    if (sz >= k) break;
    dep++;
    k -= sz;
  }
  dfs(k, dep);
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

Igor likes hexadecimal notation and considers positive integer in the hexadecimal notation interesting if each digit and each letter in it appears no more than t times. For example, if t = 3, then integers 13a13322, aaa, abcdef0123456789 are interesting, but numbers aaaa, abababab and 1000000 are not interesting.

Your task is to find the k-th smallest interesting for Igor integer in the hexadecimal notation. The integer should not contain leading zeros.

Input

The first line contains the two integers k and t (1 ≤ k ≤ 2·109, 1 ≤ t ≤ 10) — the number of the required integer and the maximum number of times some integer or letter can appear in interesting integer.

It can be shown that the answer always exists for such constraints.

Output

Print in the hexadecimal notation the only integer that is the k-th smallest interesting integer for Igor.

Examples

Input

17 1


Output

12


Input

1000000 2


Output

fca2c

Note

The first 20 interesting integers if t = 1: 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, 10, 12, 13, 14, 15. So the answer for the first example equals 12.

### Response

```cpp
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
namespace IO {
const int L = 1 << 15;
char ibuf[L | 1], *iS = ibuf, *iT = ibuf, obuf[L | 1], *oS = obuf,
                  *oT = obuf + L, c, st[66];
int tp = 0, f;
inline char gc() {
  if (iS == iT) iT = (iS = ibuf) + fread(ibuf, sizeof(char), L, stdin);
  return (*iS++);
}
inline void flush() {
  fwrite(obuf, sizeof(char), oS - obuf, stdout);
  oS = obuf;
}
inline void pc(char c) {
  *oS++ = c;
  if (oS == oT) flush();
}
inline long long read() {
  long long x = 0;
  f = 1, c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c & 15);
  return x * f;
}
inline void write(long long x) {
  if (!x) putchar('0');
  if (x < 0) putchar('-'), x = -x;
  while (x) st[++tp] = x % 10 + '0', x /= 10;
  while (tp) putchar(st[tp--]);
}
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
inline void wri(long long x) { write(x), putchar(' '); }
struct IOflusher {
  ~IOflusher() { flush(); }
} _ioflusher_;
}  // namespace IO
using IO::read;
using IO::wri;
long long k, t, deep;
long long C[20][20], f[20][20];
int a[23], num[20], dep;
long long dp(int x) {
  for (register int i = (0); i <= int(16); ++i) f[0][i] = 1;
  for (register int i = (1); i <= int(x); ++i) {
    for (register int j = (1); j <= int(16); ++j) {
      f[i][j] = 0;
      for (register int k = (0); k <= int(min(i, a[j])); ++k) {
        f[i][j] += f[i - k][j - 1] * C[i][k];
      }
    }
  }
  return f[x][16];
}
void dfs(int k, int x) {
  if (x == 0) return;
  int limitl = (x == dep) ? 2 : 1;
  for (register int i = (limitl); i <= int(16); ++i) {
    if (!a[i]) continue;
    a[i]--;
    long long sz = dp(x - 1);
    if (sz >= k) {
      if (i - 1 >= 10) {
        printf("%c", i - 1 + 'a' - 10);
      } else {
        printf("%d", i - 1);
      }
      dfs(k, x - 1);
      break;
    }
    k -= sz;
    a[i]++;
  }
}
int main() {
  k = read(), t = read();
  for (register int i = (1); i <= int(16); ++i) a[i] = t;
  C[0][0] = 1;
  for (register int i = (1); i <= int(10); ++i) {
    C[i][0] = 1;
    for (register int j = (1); j <= int(i); ++j)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
  }
  dep = 1;
  while (true) {
    a[2]--;
    long long sz = dp(dep - 1) * 15;
    a[2]++;
    if (sz >= k) break;
    dep++;
    k -= sz;
  }
  dfs(k, dep);
  return 0;
}

```