#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int MOD = 1000000007;
int mod(const ll &x) { return x > 0 ? x % MOD : (x + MOD) % MOD; }
int modm(const ll &x, const ll &m) { return (x % MOD) * (m % MOD) % MOD; }
int modpow(ll x, ll p) {
  int ret = 1;
  while (p > 0) {
    if (p & 1) ret = modm(ret, x);
    x = modm(x, x);
    p >>= 1;
  }
  return ret;
}
int modd(ll x, ll d) { return modm(x, modpow(d, MOD - 2)); }
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  constexpr int FACT = 100000;
  int fact[FACT];
  fact[0] = 1;
  for (int i = 1; i < (FACT); i++) fact[i] = modm(fact[i - 1], i);
  auto comb = [&](int x, int y) {
    int r = fact[x];
    r = modd(r, fact[y]);
    r = modd(r, fact[x - y]);
    return r;
  };
  string n;
  cin >> n;
  int k;
  cin >> k;
  int ns = n.size();
  ll ans = 0;
  for (int i = 1; i < (ns + 1); i++) {
    if (i < k) continue;
    if (i != ns) {
      ans += comb(i - 1, k - 1) * pow(9, k);
    } else {
      if (k == 1)
        ans += n[0] - '0';
      else {
        int k2 = 0;
        while (k2 < k - 1) {
          int c = n[k2] - '0';
          ans += (c - 1) * comb(ns - (k2 + 1), k - k2 - 1) *
                 (int)pow(9, k - k2 - 1);
          k2++;
        }
        ans += (ns - k) * 9;
        ans += n[k - 1] - '0';
      }
    }
    cerr << ans << endl;
  }
  cout << ans << '\n';
  return 0;
}
