#include <bits/stdc++.h>
int combination(int a, int b) {
  if (b == 0 || b == a)
    return 1;
  else if (b == 1)
    return a;
  return combination(a - 1, b - 1) + combination(a - 1, b);
}
int k, i, j, q = 0, r = 0;
char n[101];
int main() {
  scanf("%s%d", n, &k);
  for (i = 0; n[i] != '\0'; i++)
    ;
  if (k == 1) r = 9 * i - (9 - n[0] + 48);
  if (k == 2) {
    q = combination(i, k);
    printf("%d\n", q);
    r = 9 * 9 * q - (9 * (i - 1) * (9 - n[0] + 48) + (9 - n[1] + 48));
  }
  if (k == 3) {
    q = combination(i, k);
    r = 9 * 9 * 9 * q - (9 * 9 * (i - 1) * (9 - n[0] + 48) +
                         9 * (i - 2) * (9 - n[1] + 48) + (9 - n[2] + 48));
  }
  printf("%d", r);
  return 0;
}
