#include <bits/stdc++.h>
using namespace std;
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0) {
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}
uint64_t lcm(uint64_t m, uint64_t n) { return (m * n) / gcd(m, n); }
void comb(vector<vector<uint64_t> > &v) {
  for (uint64_t i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (uint64_t k = 1; k < v.size(); k++) {
    for (uint64_t j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
    }
  }
}
bool is_product_overflow(uint64_t a, uint64_t b) {
  uint64_t prod = a * b;
  return (prod / b != a);
}
void primeFactorization(uint64_t a, list<uint64_t> &factors) {
  long i, sq;
  if (a % 2 == 0) {
    factors.push_back(2);
    primeFactorization(a / 2, factors);
    return;
  }
  sq = sqrt(a);
  for (i = 3; i <= sq; i += 2) {
    if (a % i == 0) {
      factors.push_back(i);
      primeFactorization(a / i, factors);
      return;
    }
  }
  if (a != 1) {
    factors.push_back(a);
  }
}
int64_t modinv(int64_t a, int64_t m) {
  int64_t b = m, u = 1, v = 0;
  while (b) {
    int64_t t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
int64_t countComb(int length, int k) {
  if (k < 1) return 0;
  if (length < k) return 0;
  int64_t totalCombination = length * 9;
  for (int i = 1; i < k; i++) {
    totalCombination *= length - i;
    totalCombination /= i + 1;
    totalCombination *= 9;
  }
  return totalCombination;
}
signed main() {
  string n;
  cin >> n;
  int k;
  cin >> k;
  int size = n.size();
  int64_t totalComb = 0;
  totalComb = countComb(size - 1, k);
  int pos = 0;
  int count = 0;
  while (true) {
    if (count == k) break;
    if (pos > n.size() - 1) break;
    if (n[pos] != '0') {
      count++;
      int cNum = atoi(n.substr(pos, 1).c_str());
      if (count == k) {
        totalComb += cNum;
        totalComb += countComb(size - pos - 1, 1);
      }
      if (cNum > 1) {
        totalComb += (cNum - 1) * countComb(size - pos - 1, k - count);
      }
    }
    pos++;
  }
  cout << totalComb << endl;
  return 0;
}
