#include <bits/stdc++.h>
using namespace std;
long long C9(int k, int n) {
  if (n < k) return 0;
  int s = min(k, n);
  if (s == 0) return 1;
  if (1 == s) return n * 9;
  if (2 == s) return n * (n - 1) / 2 * 9 * 9;
  return n * (n - 1) * (n - 2) / 3 / 2 * 9 * 9 * 9;
}
int main() {
  string S;
  int K;
  cin >> S >> K;
  int N = S.size();
  vector<int> A;
  for (int i = 0; i < N; i++)
    if ('0' != S.at(i)) A.push_back(S.at(i) - '0');
  long long SS = 0;
  int NN = A.size();
  if (NN < K) return 0;
  if (K == 1) {
    SS = A.at(0);
    SS += C9(1, NN - 1);
  } else if (K == 2) {
    SS = A.at(1);
    SS += C9(1, NN - 2);
    SS += (A.at(0) - 1) * C9(1, NN - 1);
    SS += C9(2, NN - 1);
  } else if (K == 3) {
    SS = A.at(2);
    SS += C9(1, NN - 3);
    SS += (A.at(1) - 1) * C9(1, NN - 2);
    SS += C9(2, NN - 2);
    SS += (A.at(0) - 1) * C9(2, NN - 1);
    SS += C9(3, NN - 1);
  }
  cout << SS << endl;
  return 0;
}
