#include <bits/stdc++.h>
using namespace std;
int binom(int64_t N, int64_t K) {
  if (K < 0 || N < K) return 0;
  int ret = 1;
  for (int i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
int main() {
  string S;
  int K;
  cin >> S >> K;
  int L = S.size();
  vector<long long> c(L + 1);
  for (int i = 0; i < (int)L; i++) c[i + 1] += c[i] + (S[i] - '0' != 0);
  long long ans = 0;
  for (int i = 0; i < (int)L; i++) {
    int x = S[i] - '0';
    if (c[i] > K || x == 0) continue;
    ans += (x - 1) * binom(L - i - 1, K - c[i] - 1) * pow(9, K - c[i] - 1);
    ans += binom(L - i - 1, K - c[i]) * pow(9, K - c[i]);
  }
  ans += (c[L + 1] == K);
  cout << ans << endl;
}
