#include <bits/stdc++.h>
using namespace std;
bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
  return arg1.first > arg2.first;
}
template <class T>
void chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
}
template <class T>
void chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
}
int main(void) {
  string s;
  cin >> s;
  long long k;
  cin >> k;
  long long n;
  n = s.size();
  vector<vector<long long>> dp1(n + 1, vector<long long>(k + 1, 0));
  vector<vector<long long>> dp0(n + 1, vector<long long>(k + 1, 0));
  long long num;
  dp1.at(0).at(0) = 1;
  for (long long in = 0; in < n; in++) {
    for (long long ik = 0; ik < k; ik++) {
      num = s.at(in) - '0';
      if (num > 0) {
        dp1.at(in + 1).at(ik + 1) += dp1.at(in).at(ik);
        dp0.at(in + 1).at(ik + 1) +=
            dp0.at(in).at(ik) * 9 + dp1.at(in).at(ik) * (num - 1);
        dp0.at(in + 1).at(ik) += dp0.at(in).at(ik) + dp1.at(in).at(ik);
      } else {
        dp1.at(in + 1).at(ik) += dp1.at(in).at(ik);
        dp0.at(in + 1).at(ik + 1) += dp0.at(in).at(ik) * 9;
        dp0.at(in + 1).at(ik) += dp0.at(in).at(ik);
      }
    }
  }
  cout << dp1.at(n).at(k) + dp0.at(n).at(k) << endl;
  return 0;
}
