#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll comb(int n, int k) {
  ll pro = 1;
  ll div = 1;
  n++;
  for (int i = 1; i <= k; i++) {
    pro *= n - i;
    div *= i;
  }
  return pro / div;
}
ll pow(int a, int b) {
  ll res = 1;
  for (int i = 0; i < b; i++) {
    res *= a;
  }
  return res;
}
int main() {
  string N;
  cin >> N;
  int K;
  cin >> K;
  ll ans = comb(N.size() - 1, K) * pow(9, K);
  int top = (int)N[0] - '0';
  top--;
  int sec = 0;
  int thr = 0;
  for (int i = 1; i < N.size(); i++) {
    if (N[i] != 0) {
      if (sec == 0) {
        sec = i;
      } else {
        thr = i;
        break;
      }
    }
  }
  ans += comb(N.size() - 1, K - 1) * pow(9, K - 1) * top;
  ans += comb(N.size() - sec - 1, K - 1) * pow(9, K - 1);
  if (K >= 2) {
    top = (int)N[sec] - '0';
    ans += comb(N.size() - thr - 1, K - 2) * pow(9, K - 2) * top;
    if (K >= 3) {
      int a = (int)N[thr] - '0';
      ans += top * a;
    }
  }
  cout << ans << endl;
  return 0;
}
