#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  if (b < 0) return 0;
  long long prod = 1;
  while (b) {
    if (b & 1) prod = (prod * a);
    a = (a * a);
    b >>= 1;
  }
  return prod;
}
long long fact(long long n) {
  if (n <= 0) return 1;
  return fact(n - 1) * n;
}
long long ncr(long long n, long long r) {
  if (r > n) return 0;
  return fact(n) / (fact(r) * (fact(n - r)));
}
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int k;
  cin >> k;
  long long temp = k, final_sum = 0, cnt = 0;
  for (int i = 0; i < n && temp >= 1; i++) {
    int number = s[i] - '0';
    if (number) {
      long long size = n - i;
      long long sum = ncr(size - 1, temp);
      final_sum += sum * power(9, temp);
      if (number > 1) {
        sum = ncr(size - 1, temp - 1);
        final_sum += sum * power(9, temp - 1) * (number - 1);
      }
      temp--;
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] != '0') cnt++;
  }
  if (cnt >= k) final_sum++;
  cout << final_sum << endl;
}
