#include <bits/stdc++.h>
using namespace std;
inline int rd() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return f * x;
}
char n[105];
int k, len;
long long s[200005], ans;
void dfs(int x, int y, long long res, bool f) {
  if (f == 1) {
    ans += res;
    return;
  }
  if (x == len + 1) {
    if (y == k) ans += res;
    return;
  }
  dfs(x + 1, y, res, f);
  dfs(x + 1, y + 1, res * (n[x] - '0' - 1), 1);
  dfs(x + 1, y + 1, res, f);
}
void Pre() {
  s[0] = 1;
  for (int i = 1; i <= 200005; i++) s[i] = s[i - 1] * i;
}
long long C(int a, int b) {
  if (a < 0 || b < 0) return 1;
  return s[a] / s[b] / s[a - b];
}
int main() {
  scanf("%s", n + 1);
  k = rd();
  Pre();
  len = strlen(n + 1);
  int x = n[1] - '0';
  ans = 9 * C(len - 1, k - 1) * (x - 1);
  dfs(2, 0, 0, 0);
  printf("%lld\n", ans);
  return 0;
}
