#include <bits/stdc++.h>
using namespace std;
int64_t com(int64_t n, int64_t r) {
  if (r <= 0)
    return 0;
  else if (r == 1)
    return n;
  else if (r == 2)
    return (n * (n - 1)) / 2;
  return (n * (n - 1) * (n - 2)) / 6;
}
int main() {
  string S;
  int K;
  cin >> S;
  cin >> K;
  int N = S.size();
  int64_t count = 0;
  for (int m = 0; m < K; m++) {
    int top = S[m] - '0';
    int keta = N - m;
    int uk = K - m;
    for (int k = 0; k < top; k++) {
      if (k == 0) {
        count += com(keta - 1, uk) * pow(9, uk);
      } else {
        int d = com(keta - 1, uk - 1) * pow(9, uk - 1);
        count += d;
        if (d == 0) count++;
      }
    }
  }
  count++;
  cout << count << endl;
  return 0;
}
