#include <bits/stdc++.h>
int l, k;
char s[110];
long long dp0[110][4], dp1[110][4];
int main() {
  freopen("test.in", "r", stdin);
  scanf("%s%d", s, &k);
  l = strlen(s);
  dp1[0][0] = 1;
  dp0[0][0] = 0;
  dp0[0][1] = 1;
  dp1[0][1] = s[0] - '0' - 1;
  for (int i = 1; i < l; i++) {
    dp1[i][0] = 1;
    for (int j = 1; j <= k; j++) {
      if (s[i] == '0') {
        dp0[i][j] = dp0[i - 1][j];
        dp1[i][j] = dp1[i - 1][j] + dp1[i - 1][j - 1] * 9;
      } else {
        dp0[i][j] = dp0[i - 1][j - 1];
        dp1[i][j] = dp0[i - 1][j - 1] * (s[i] - '0' - 1) + dp0[i - 1][j] +
                    dp1[i - 1][j] + dp1[i - 1][j - 1] * 9;
      }
    }
  }
  printf("%lld\n", dp0[l - 1][k] + dp1[l - 1][k]);
  return 0;
}
