#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  int K;
  cin >> S >> K;
  int N = S.size();
  vector<int> A;
  A.push_back(0);
  for (int i = 0; i < N; i++) A.push_back(S.at(i) - '0');
  int NN = A.size();
  vector<vector<int>> DPOK(NN + 1, vector<int>(K + 2, 0));
  vector<vector<int>> DPUK(NN + 1, vector<int>(K + 2, 0));
  DPUK.at(0).at(K) = 1;
  for (int i = 1; i <= NN - 1; i++) {
    for (int j = 0; j < K + 1; j++) {
      DPUK.at(i).at(j) = DPUK.at(i - 1).at(j + 1);
      DPOK.at(i).at(j) = DPOK.at(i - 1).at(j) + DPOK.at(i - 1).at(j + 1) * 9 +
                         DPUK.at(i - 1).at(j);
      if (0 < A.at(i))
        DPOK.at(i).at(j) += DPUK.at(i - 1).at(j + 1) * (A.at(i) - 1);
    }
  }
  int SS = DPOK.at(NN - 1).at(0) + DPUK.at(NN - 1).at(0);
  cout << SS << endl;
  return 0;
}
