#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k) {
  if (n < k) return 1;
  if (n < 0 || k < 0) return 1;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  COMinit();
  string str;
  cin >> str;
  long long k;
  cin >> k;
  long long n = (int)str.size();
  long long ans = 0;
  long long sum = 0;
  long long ct = 0, prev = 0;
  for (int i = 0; i < n; i++) {
    sum += str[i] - '0';
    if ((str[i] - '0') != 0) ct++;
  }
  long long f = 1;
  for (int i = 0; i < k; i++) {
    f = f * 9;
  }
  long long store = sum;
  for (int i = k; i < n + 1; i++) {
    if (i == n) {
      long long x = 0;
      long long tmp = k;
      if (k == 1) {
        x = str[0] - '0';
        x--;
        if (x <= 0) x = 1;
      } else if (k == 2) {
        sum -= (str[0] - '0');
        ct--;
        x = ((str[0] - '0') - 1) * 9 * COM(n - 1, 1);
        x += (sum);
      } else {
        sum -= str[0] - '0';
        for (int p = 1; p < n; p++) {
          sum -= str[p] - '0';
          long long r = str[p] - '0';
          if (r != 0) {
            x += (r - 1) * sum;
          }
        }
      }
      ans += x;
    } else {
      ans += f * COM(i - k + 1, k - 1);
    }
    prev = ans;
  }
  printf("%lld", ans);
  printf("\n");
  return 0;
}
