#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000;
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 % 1000000007;
    inv[i] = 1000000007 - inv[1000000007 % i] * (1000000007 / i) % 1000000007;
    finv[i] = finv[i - 1] * inv[i] % 1000000007;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % 1000000007) % 1000000007;
}
int main() {
  COMinit();
  string n;
  int k;
  cin >> n;
  cin >> k;
  int count = 0, i = 0, result = 0;
  int mul = 1;
  for (int i = 0; i < k; i++) mul *= 9;
  while (count < k && i < n.length()) {
    if (n[i] != '0') {
      result += (int)(n[i] - '1') * mul * COM(n.length() - i, k - count - 1);
      mul /= 9;
      result += mul * COM(n.length() - i, k - count - 1);
      count++;
    }
    i++;
  }
  cout << result;
  return 0;
}
