#include <bits/stdc++.h>
using namespace std;
long long nCr(long long n, long long r) {
  if (r == 0)
    return 1;
  else if (r == 1)
    return n;
  return n * (n - 1) / 2;
}
long long numPossib(long long n, long long k) {
  long long ans = 0, i;
  for (i = k; i != n + 1; i++) ans += nCr(i - 1, k - 1);
  if (k == 3)
    return ans * 9 * 9 * 9;
  else if (k == 2)
    return ans * 9 * 9;
  return ans * 9;
}
long long lastPossib(long long n, long long k, string &num) {
  long long p1 = stoi(num.substr(0, 1));
  if (k == 1)
    return p1;
  else if (k == 2) {
    long long i, ans;
    ans = 0;
    for (i = 1; i != n; i++)
      if (num[i] != '0') break;
    if (i < n) ans = stoi(num.substr(i, 1)) + nCr(n - i - 1, 1) * 9;
    return ans + (p1 - 1) * 9 * nCr(n - 1, 1);
  } else {
    long long i, j, ans;
    ans = 0;
    for (i = 1; i != n - 1; i++) {
      if (num[i] == '0') continue;
      ans += (stoi(num.substr(i, 1)) - 1) * nCr(n - 1 - i, 1) * 9;
      for (j = i + 1; j != n; j++)
        if (num[j] != '0') break;
      if (j < n) ans += stoi(num.substr(j, 1)) + nCr(n - j - 1, 1) * 9;
    }
    return (p1 - 1) * 9 * 9 * nCr(n - 1, 2) + ans;
  }
  return 0;
}
int main() {
  string num;
  cin >> num;
  long long n = num.size();
  long long k;
  cin >> k;
  if (n < k) {
    cout << 0;
    exit(0);
  }
  long long ans = numPossib(n - 1, k);
  ans += lastPossib(n, k, num);
  cout << ans;
  return 0;
}
