#include <bits/stdc++.h>
using namespace std;
int N, K;
char buf[105];
long long int dp[105][2][4];
int main() {
  scanf("%s", buf);
  scanf("%d", &K);
  for (N = 0; buf[N] != '\0'; N++)
    ;
  for (int i = 0; i <= N; i++) {
    for (int k = 0; k < 2; k++) {
      for (int a = 0; a <= K; a++) {
        dp[i][k][a] = 0;
      }
    }
  }
  dp[0][true][1] = 1;
  dp[0][false][1] = (buf[0] - '0') - 1;
  dp[0][false][0] = 1;
  for (int i = 1; i < N; i++) {
    for (int k = 1; k <= K; k++) {
      if (buf[i] != '0') {
        dp[i][true][k] += dp[i - 1][true][k - 1];
      } else {
        dp[i][true][k] += dp[i - 1][true][k];
      }
    }
    for (int k = 1; k <= K; k++) {
      if (buf[i] == '0') {
      } else {
        dp[i][false][k] += dp[i - 1][true][k];
        dp[i][false][k] += dp[i - 1][true][k - 1] * ((buf[i] - '0') - 1);
      }
    }
    for (int k = 0; k <= K; k++) {
      dp[i][false][k] += dp[i - 1][false][k];
      dp[i][false][k] += dp[i - 1][false][k - 1] * 9;
    }
  }
  printf("%lld", dp[N - 1][true][K] + dp[N - 1][false][K]);
  return 0;
}
