#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long long int INF = (long long int)1e15;
struct Combination {
  Combination(long long int n) {
    mNumTbl.resize(n + 1);
    mInverseNumTbl.resize(n + 1);
    mNumTbl[0] = 1;
    mInverseNumTbl[0] = 1;
    for (long long int(i) = (1); (i) < (n + 1); ++(i)) {
      mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
    }
    for (long long int(i) = (1); (i) < (n + 1); ++(i)) {
      mInverseNumTbl[i] = modpow(mNumTbl[i]);
    }
  }
  long long int get(long long int n, long long int r) {
    if (n < r || n < 0) return 0;
    return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) %
           MOD;
  }
  long long int modpow(long long int n) {
    long long int s = 1, p = n;
    for (long long int i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD) {
      if (((MOD - 2) & (1 << i)) == 0) continue;
      s *= p;
      s %= MOD;
    }
    return s;
  }
  vector<long long int> mInverseNumTbl;
  vector<long long int> mNumTbl;
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  long long int K;
  cin >> S >> K;
  Combination cmb(200);
  long long int ans = 0;
  long long int N = S.length();
  long long int n = 0;
  for (long long int(i) = (0); (i) < (N); ++(i)) {
    if (S[i] > '0') n++;
  }
  if (K == n) ans++;
  for (long long int(i) = (0); (i) < (N); ++(i)) {
    if (S[i] == '0') continue;
    ans += cmb.get(N - 1 - i, K) * pow(9, K);
    ans += cmb.get(N - 1 - i, K - 1) * pow(9, K - 1) * std::max(S[i] - '1', 0);
    K--;
  }
  cout << ans << endl;
  return 0;
}
