#include <bits/stdc++.h>
using namespace std;
long long combination(long long a, long long b) {
  long long s = 1;
  long long t = 1;
  long long u = 1;
  for (int i = a; i > (a - b); i--) {
    s *= i;
  }
  for (int i = 1; i <= b; i++) {
    t *= i;
  }
  return s / (t * u);
}
long long recurcice(string N, long long K) {
  cerr << N << "K=" << K << endl;
  if (K == 0) {
    return 0;
  }
  int degree = N.length();
  if (degree == 1) {
    return stoi(N);
  }
  long long ans = 0;
  ans += combination(degree - 1, K) * pow(9, K);
  ans += combination(degree - 1, K - 1) * pow(9, K - 1) * (N[0] - '1');
  cerr << "degree=" << degree << endl;
  cerr << N << "ans=" << ans << endl;
  if (K == 1) {
    ans++;
  }
  for (int i = 1; i < degree; i++) {
    if (N[i] != '0') {
      cerr << N[i] << endl;
      ans += recurcice(N.substr(i), K - 1);
      break;
    }
  }
  return ans;
}
void solve(string N, long long K) { cout << recurcice(N, K) << endl; }
int main() {
  string N;
  cin >> N;
  long long K;
  scanf("%lld", &K);
  solve(N, K);
  return 0;
}
