#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1ll << 60;
vector<ll> fac(300001);
vector<ll> ifac(300001);
ll mpow(ll x, ll n) {
  ll ans = 1;
  while (n != 0) {
    if (n & 1) ans = ans * x % MOD;
    x = x * x % MOD;
    n = n >> 1;
  }
  return ans;
}
ll comb(ll a, ll b) {
  if (a == 0 && b == 0) return 1;
  if (a < b || a < 0) return 0;
  ll tmp = ifac[a - b] * ifac[b] % MOD;
  return tmp * fac[a] % MOD;
}
void init() {
  fac[0] = 1;
  ifac[0] = 1;
  for (ll i = 0; i < 300000; i++) {
    fac[i + 1] = fac[i] * (i + 1) % MOD;
    ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
  }
}
bool f(string &l, string &r) {
  ll N = l.size();
  for (ll i = (0); i < (N); ++i) {
    if (l[i] > r[i])
      return true;
    else if (l[i] < r[i])
      return false;
  }
  return false;
}
string S;
ll K;
int main(int argc, char **argv) {
  cin >> S >> K;
  ;
  ll N = S.size();
  init();
  ll res{0};
  if (N > 1) res += 9 * comb(1, K);
  for (ll i = 2; i < N; ++i) {
    if (i == K)
      res += pow(9, K) * (comb(i, K));
    else
      res += pow(9, K) * (comb(i - 1, K - 1));
  }
  res += (S.front() - '0' - 1) * pow(9, K - 1) * (comb(N - 1, K - 1));
  if (K == 3) {
    for (ll i = 1; i < S.size() - 1; ++i) {
      for (ll j = i + 1; j < S.size(); ++j) {
        res += (S[i] - '0') * (S[j] - '0');
      }
    }
  } else if (K == 2) {
    for (ll i = 1; i < S.size(); ++i) res += S[i] - '0';
  } else
    ++res;
  std::cout << res << std::endl;
}
