#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long fac[200007], finv[200007], inv[200007];
void cominit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < 200007; 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(long long n, long long k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  cominit();
  string s;
  long long k;
  cin >> s >> k;
  long long n = s.length();
  long long ans = 0;
  if (n < k) {
    cout << 0 << endl;
    return 0;
  }
  while (k && n) {
    ans += com(n - 1, k) * pow(9LL, k);
    long long num = (s[0] - '0');
    for (int i = 1; i < num; i++) {
      ans += com(n - 1, k - 1) * pow(9LL, k - 1);
    }
    k--;
    n--;
    s = s.substr(1, n);
  }
  if (n == k) ans++;
  cout << ans + 1 << endl;
  return 0;
}
