#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main() {
  string N;
  cin >> N;
  int t = N.size();
  int K;
  cin >> K;
  if (t < K) {
    cout << 0 << endl;
    return 0;
  }
  long ans = 1;
  for (int i = (0), i_end_ = (K); i < i_end_; i++) {
    ans *= (t - i);
    ans *= 9;
  }
  for (int i = (0), i_end_ = (K); i < i_end_; i++) {
    ans /= i + 1;
  }
  int cnt = 0;
  for (int i = (0), i_end_ = (t); i < i_end_; i++) {
    int x = N[i] - '0';
    if (x != 0) {
      long tmp = 9 - x;
      cnt++;
      for (int j = (0), j_end_ = (K - cnt); j < j_end_; j++) {
        tmp *= t - i - 1;
        tmp *= 9;
      }
      for (int j = (0), j_end_ = (K - cnt); j < j_end_; j++) {
        tmp /= j + 1;
      }
      ans -= tmp;
      if (K == cnt) break;
    }
  }
  cout << ans << endl;
}
