#include <bits/stdc++.h>
using namespace std;
long long combination(long long n, long long r) {
  long long ret = 1;
  for (long long i = 0; i < (long long)(r); i++)
    ret = (ret * (n - i)) / (i + 1);
  return ret;
}
long long getans(long long *n, long long k, int l) {
  if (l <= 0) return 1;
  if (k == 0) return 1;
  if (k > l) return 0;
  if (n[0] == 0) return getans(n + 1, k, l - 1);
  long long k9m = 1;
  for (long long i = 0; i < (long long)(k - 1); i++) k9m *= 9;
  long long k9 = k9m * 9;
  return combination(l - 1, k) * k9 +
         (n[0] - 1) * combination(l - 1, k - 1) * k9m +
         getans(n + 1, k - 1, l - 1);
}
int main() {
  string s;
  long long k;
  cin >> s >> k;
  long long *n = new long long[s.length()];
  for (long long i = 0; i < (long long)(s.length()); i++) n[i] = s[i] - '0';
  cout << getans(n, k, s.length());
  delete n;
  return 0;
}
