#include <bits/stdc++.h>
using namespace std;
int64_t com(int64_t n, int64_t r) {
  if (r <= 0)
    return 1;
  else if (r == 1)
    return n;
  else if (r == 2)
    return (n * (n - 1)) / 2;
  return (n * (n - 1) * (n - 2)) / 6;
}
int64_t lpow(long long N, long long K) {
  long long res = 1;
  for (int i = 0; i < K; ++i) res *= N;
  return res;
}
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) {
    int64_t top_digit = S[m] - '0';
    int64_t keta = N - m;
    int64_t uk = K - m;
    if (m == K - 1) {
      top_digit++;
    }
    for (int k = 0; k < (top_digit); ++k) {
      if (keta - 1 < uk && k == 0) {
        continue;
      }
      if (keta - 1 < uk - 1) {
        continue;
      }
      int d = 0;
      if (k == 0) {
        d = com(keta - 1, uk) * lpow(9, uk);
        if (d == 0 && m > 0) {
          d = 1;
        }
      } else {
        d = com(keta - 1, uk - 1) * lpow(9, uk - 1);
        if (d == 0) {
          d = 1;
        }
      }
      count += d;
    }
  }
  cout << count << endl;
  return 0;
}
