#include <bits/stdc++.h>
using ll = long long;
using graph = std::vector<std::vector<ll>>;
using namespace std;
ll calc(ll digit, ll K) {
  if (digit < K) {
    return 0;
  }
  ll result = 1;
  for (ll i = 0; i < K; i++) {
    result *= digit - i;
  }
  for (ll i = 1; i < K + 1; i++) {
    result /= i;
  }
  for (ll i = 0; i < K; i++) {
    result *= 9;
  }
  return result;
}
int main() {
  string N;
  int K;
  cin >> N;
  cin >> K;
  int digit = N.size();
  int head = 0;
  for (int i = 0; i < 3; i++) {
    head *= 10;
    head += N[i] - '0';
  }
  ll sum = 0;
  for (int i = 0; i <= head; i++) {
    int nonZeroCount = 0;
    int tmpi = i;
    while (tmpi != 0) {
      if (tmpi % 10 != 0) {
        nonZeroCount += 1;
      }
      tmpi /= 10;
    }
    if (K < nonZeroCount || digit < 3) {
      continue;
    }
    sum += calc(digit - 3, K - nonZeroCount);
  }
  cout << sum << endl;
}
