#include <bits/stdc++.h>
using namespace std;
template <class t>
ostream& operator<<(ostream& os, const vector<t>& v) {
  os << "{";
  for (int i = (int)(0); i < (int)(v.size()); i++) {
    if (i) os << ", ";
    os << v[i];
  }
  return os << "}";
}
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const long long mod = 1e9 + 7;
int char2int(char c) { return int(c - '0'); }
int main() {
  string N;
  int K;
  cin >> N >> K;
  int D = N.size();
  vector<vector<long long> > dp(D, vector<long long>((K + 1) * 2));
  dp[0][0] = 1;
  dp[0][0 + K + 1] = 0;
  dp[0][1] = char2int(N[0]) - 1;
  dp[0][1 + K + 1] = 1;
  for (int i = (int)(1); i < (int)(D); i++) {
    int tmp = char2int(N[i]);
    for (int k = (int)(0); k < (int)(K + 1); k++) {
      if (k) {
        dp[i][k] += dp[i - 1][k - 1] * 9;
        if (tmp) dp[i][k] += dp[i - 1][k + K] * (tmp - 1);
        dp[i][k + K + 1] += dp[i - 1][k + K] * 1;
      }
      dp[i][k] += dp[i - 1][k] * 1;
      if (tmp)
        dp[i][k] += dp[i - 1][k + K + 1] * 1;
      else
        dp[i][k + K + 1] += dp[i - 1][k + K + 1];
    }
  }
  cout << dp[D - 1][K] + dp[D - 1][2 * K + 1] << endl;
  return 0;
}
