#include <bits/stdc++.h>
using namespace std;
char *fs, *ft, buf[1 << 15];
inline char getc() {
  return (fs == ft &&
          (ft = (fs = buf) + fread(buf, 1, 1 << 15, stdin), fs == ft))
             ? 0
             : *fs++;
}
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const long long MAXN = 110;
char a[MAXN];
long long f[MAXN][4];
long long n, k;
long long c[MAXN];
inline long long dfs(long long x, long long w, long long limit, long long s) {
  if (w < 0) return 0;
  if (!limit && f[x][w] != -1) return f[x][w];
  if (!x) {
    if (!w) return f[x][w] = 1;
    return f[x][w] = 0;
  }
  long long maxx = limit ? c[x] : 9;
  long long cnt = 0;
  for (long long i = 0; i <= maxx; ++i) {
    if (s && i == 0) {
      cnt += dfs(x - 1, w, 0, s);
      continue;
    }
    if (i == 0)
      cnt += dfs(x - 1, w, 0, 0);
    else
      cnt += dfs(x - 1, w - 1, limit && i == maxx, 0);
  }
  if (!limit && !s) f[x][w] = cnt;
  return cnt;
}
int main() {
  memset(f, -1, sizeof(f));
  scanf("%s", a + 1);
  n = strlen(a + 1);
  k = read();
  for (long long i = 1; i <= n; ++i) c[i] = a[i] - '0';
  reverse(c + 1, c + 1 + n);
  printf("%lld\n", dfs(n, k, 1, 1));
  return 0;
}
