#include <bits/stdc++.h>
using namespace std;
long long N_list[103];
long long K;
long long dp0[100][4];
long long dp1[100][4];
long long rec(long long i) {
  if (i == 0) {
    dp0[i][0] = 1;
    dp0[i][1] = N_list[i] - 1;
    dp1[0][1] = 1;
  }
  for (long long j = 0; j <= K; ++j) {
    dp0[i + 1][j] += dp0[i][j];
    if (N_list[i + 1] != 0) dp0[i + 1][j] += dp1[i][j];
    if (j != 0) {
      dp0[i + 1][j] += dp0[i][j - 1] * 9;
      dp0[i + 1][j] += dp1[i][j - 1] * (N_list[i + 1] - 1);
    }
    if (N_list[i + 1] == 0) dp1[i + 1][j] += dp1[i][j];
    if (N_list[i + 1] != 0 & j != 0) dp1[i + 1][j] += dp1[i][j - 1];
  }
}
int main() {
  string N;
  cin >> N;
  long long L = N.size();
  cin >> K;
  long long k_const = K;
  for (long long i = 0; i < (long long)(L); i++)
    N_list[i] = (long long)stoi(N.substr(i, 1));
  memset(dp0, 0, sizeof(dp0));
  memset(dp1, 0, sizeof(dp1));
  for (long long i = 0; i < (long long)(L + 1); i++) {
    rec(i);
  }
  long long ans = dp0[L - 1][k_const] + dp1[L - 1][k_const];
  printf("%lld\n", ans);
}
