#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcd(long long a, long long b) {
  if (b == 0) return a;
  return (a / gcd(a, b)) * b;
}
vector<int> divnum(long long num) {
  int dig;
  vector<int> p;
  while (num) {
    dig = num % 10;
    p.push_back(dig);
    num /= 10;
  }
  return p;
}
int digiter(long long num) {
  int dig;
  vector<int> p;
  while (num) {
    dig = num % 10;
    p.push_back(dig);
    num /= 10;
  }
  return p.size();
}
vector<int> convertstring(string s) {
  vector<int> d;
  long long n = s.size();
  for (int i = 0; i < n; i++) {
    d.push_back(s[i] - '0');
  }
  return d;
}
map<long long, int> prime_factor(long long n) {
  map<long long, int> ret;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
vector<long long> divisor(long long n) {
  vector<long long> res;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i != 0) continue;
    res.push_back(i);
    if (i * i != n) res.push_back(n / i);
  }
  return res;
}
long long myPow(long long x, long long n, long long m) {
  if (n == 0) return 1;
  if (n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
std::vector<int> Eratosthenes(const int N) {
  std::vector<bool> is_prime(N + 1);
  for (int i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  std::vector<int> pair<long long, long long>;
  for (int i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      pair<long long, long long>.emplace_back(i);
    }
  }
  return pair<long long, long long>;
}
const long long N = 4e5 + 5;
const long long MOD = 1e9 + 7;
long long fact[N], invfact[N];
long long pow(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
long long modinv(long long k) { return pow(k, MOD - 2, MOD); }
void precompute() {
  fact[0] = fact[1] = 1;
  for (long long i = 2; i < N; i++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= MOD;
  }
  invfact[N - 1] = modinv(fact[N - 1]);
  for (long long i = N - 2; i >= 0; i--) {
    invfact[i] = invfact[i + 1] * (i + 1);
    invfact[i] %= MOD;
  }
}
long long nCr(long long x, long long y) {
  if (y > x) return 0;
  long long num = fact[x];
  num *= invfact[y];
  num %= MOD;
  num *= invfact[x - y];
  num %= MOD;
  return num;
}
string S;
long long K;
int32_t main() {
  cin >> S >> K;
  precompute();
  long long t = S.size();
  t--;
  long long ans = 0;
  auto calc = [&](long long length, long long num, long long k) {
    if (K == 0) return long long(1);
    long long res = 0;
    for (long long head = 0; head < num; head++) {
      if (head == 0) {
        res += nCr(length, k) * pow(9, k);
      } else
        res += nCr(length, k - 1) * pow(9, k - 1);
    }
    return res;
  };
  for (long long i = 0; i < S.size(); i++) {
    ans += calc(t - i, S[i] - '0', K);
    if (K == 0) break;
    if (S[i] != 0) K--;
    if (i == S.size() - 1 && K == 0 && S[i] - '0' != 0) {
      ans += 1;
    }
  }
  cout << ans << endl;
}
