#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long pow(long long N, long long k) {
  long long res = 1;
  for (int i = 0; i < k; ++i) res *= N;
  return res;
}
long long combination(int n, int k) {
  static const int maxi = 1e4 + 1;
  static vector<long long> fac(maxi, 0), finv(maxi, 0), inv(maxi, 0);
  static const int mod = 1e9 + 7;
  if (fac[0] == 0) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < maxi; 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;
    }
  }
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
string N;
int K;
long long solve(int i, int k, bool smaller) {
  if (k == 0) return 1;
  if (i == N.size()) return 0;
  if (smaller)
    return combination(N.size() - i, k) * pow((long long)9, (long long)k);
  if (N[i] == 0) return solve(i + 1, k, false);
  auto zero = solve(i + 1, k, true);
  auto mid = solve(i + 1, k - 1, true) * (N[i] - '1');
  auto last = solve(i + 1, k - 1, false);
  return zero + mid + last;
}
int main() {
  cin >> N;
  cin >> K;
  cout << solve(0, K, false) << endl;
  return 0;
}
