#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int k;
  cin >> s >> k;
  vector<vector<int>> dp0(s.size(), vector<int>(s.size() + 1));
  vector<vector<int>> dp1(s.size(), vector<int>(s.size() + 1));
  dp0.at(0).at(1) = s.at(0) - '0';
  if (s.at(0) == 0) {
    dp1.at(0).at(0) = 1;
  } else {
    dp0.at(0).at(0) = 1;
  }
  dp1.at(0).at(1) = 1;
  for (int i = (1); i < (int)(s.size()); i++) {
    for (int j = 0; j < (int)(s.size() + 1); ++j) {
      if (j != 0) {
        dp0[i][j] = 9 * (dp0[i - 1][j - 1]) + dp0[i - 1][j] +
                    (s.at(i) - '0') * dp1[i - 1][j - 1] + dp1[i - 1][j];
        dp1[i][j] = dp1[i - 1][j - 1];
      } else {
        dp0[i][j] = dp0[i - 1][j];
        dp1[i][j] = dp1[i - 1][j];
      }
    }
  }
  cout << dp0[s.size() - 1][k] + dp1[s.size() - 1][k] << endl;
}
