#include <bits/stdc++.h>
char n[101];
int k, l, dp[100][4], bd[100][4];
int max(int a, int b) { return a > b ? a : b; }
int main() {
  scanf("%s%d", n, &k);
  l = strlen(n);
  dp[0][1] = n[0] - '1';
  bd[0][1] = 1;
  for (int i = 1; i < l; i++) {
    if (n[i] == '0') {
      bd[i][1] = bd[i - 1][1];
      bd[i][2] = bd[i - 1][2];
      bd[i][3] = bd[i - 1][3];
    } else {
      bd[i][2] = bd[i - 1][1];
      bd[i][3] = bd[i - 1][2];
    }
    dp[i][1] = dp[i - 1][1] + 9 + bd[i - 1][1];
    dp[i][2] = dp[i - 1][2] + dp[i - 1][1] * 9 + bd[i - 1][1] * (n[i] - '0') +
               bd[i - 1][2];
    dp[i][3] = dp[i - 1][3] + dp[i - 1][2] * 9 + bd[i - 1][2] * (n[i] - '0') +
               bd[i - 1][3];
  }
  printf("%d", dp[l - 1][k]);
  return 0;
}
