#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() {
  string N;
  long long int K;
  cin >> N >> K;
  long long int length = N.length();
  Combination cmb(1000);
  long long int ans = 0;
  for (long long int(i) = (0); (i) < (length - 1); ++(i)) {
    long long int t = 9;
    if (K - 1 > 0) t *= cmb.get(i, K - 1) * pow(9LL, K - 1);
    ans += t;
  }
  {
    {
      long long int t = N[0] - '0' - 1;
      if (K - 1 > 0) {
        t *= cmb.get(length - 1, K - 1) * pow(9LL, K - 1);
      }
      ans += t;
    }
    if (K - 1 > 0) {
      bool nz = false;
      for (long long int b = 1; b < length; ++b) {
        if (nz) {
          long long int t = 9LL;
          if (K - 2 > 0) t *= cmb.get(length - b - 1, K - 2) * pow(9LL, K - 2);
          ans += t;
          continue;
        }
        if (N[b] - '0' == 0) continue;
        {
          long long int t = N[b] - '0' - 1;
          if (K - 2 > 0) {
            t *= cmb.get(length - b - 1, K - 2) * pow(9LL, K - 2);
          }
          ans += t;
          if (K - 2 > 0) {
            for (long long int bb = b + 1; bb < length; ++bb) {
              long long int tt = N[bb] - '0';
              ans += tt;
            }
          } else {
            ans++;
          }
        }
        nz = true;
      }
    } else {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
