#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const int MAX = 101;
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 % 1000000007ULL;
    inv[i] = 1000000007ULL -
             inv[1000000007ULL % i] * (1000000007ULL / i) % 1000000007ULL;
    finv[i] = finv[i - 1] * inv[i] % 1000000007ULL;
  }
}
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] % 1000000007ULL) % 1000000007ULL;
}
string N;
int K;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K;
  COMinit();
  int64_t ans = COM(N.size() - 1, K);
  int64_t temp = 1;
  for (int i = 0; i < K; ++i) temp *= 9;
  ans *= temp;
  for (int i = 0; i < K; ++i) {
    temp /= 9;
    ans += (int64_t)(N[i] - '1') * COM(N.size() - i - 1, K - i - 1) * temp +
           (K - i - 1 > 0 ? COM(N.size() - i - 2, K - i - 1) * temp : 1);
  }
  cout << ans << "\n";
  return 0;
}
