#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("tune=native")
#pragma GCC target("avx")
using namespace std;
const long long mod = 1000000007;
string sn;
long long k;
long long powll(long long base, long long power) {
  long long ans = 1;
  while (power) {
    if (power & 1) ans = (base * ans) % mod;
    base = (base * base) % mod;
    power >>= 1;
  }
  return ans;
}
long long facts[100010], invs[100010];
long long ncr(long long ni, long long ri) {
  return ni < ri ? 0 : facts[ni] * invs[ri] % mod * invs[ni - ri] % mod;
}
signed main() {
  long long n = 500;
  long long f = 1;
  facts[0] = 1;
  for (long long i = (long long)(1); i < (n + 1); i++) {
    f *= i;
    f %= mod;
    facts[i] = f;
  }
  long long inv = powll(f, mod - 2);
  invs[n] = inv;
  for (long long i = (long long)(n); i > 0; i--) {
    inv *= i;
    inv %= mod;
    invs[i - 1] = inv;
  }
  cin >> sn;
  cin >> k;
  long long l = ((long long)(sn).size());
  long long ret = 1;
  for (long long i = 0; i < (long long)(l); i++) {
    if (!k) break;
    if (sn[i] == '0') continue;
    ret += ncr(l - i - 1, k) * powll(9, k);
    cerr << ret << endl;
    ret += (sn[i] - '1') * ncr(l - i - 1, k - 1) * powll(9, k - 1);
    cerr << ret << endl;
    k--;
  }
  cout << ret << endl;
}
