#include <bits/stdc++.h>
using namespace std;
long long comb(int n, int k) {
  vector<vector<long long>> v(n + 1, vector<long long>(n + 1));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int k = 1; k < v.size(); k++) {
    for (int j = 1; j < k; j++) {
      v[k][j] = v[k - 1][j - 1] + v[k - 1][j];
    }
  }
  return v[n][k];
}
int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  if (n < k) {
    cout << 0 << endl;
    return 0;
  }
  long long ans = 0;
  for (int i = k; i <= n - 1; i++) {
    long long now = 9 * comb(i - 1, k - 1);
    for (int j = 0; j < (k - 1); ++j) now *= 9;
    ans += now;
  }
  int f0 = s[0] - '0', f1, f2;
  int non_zero_index1 = -1;
  int non_zero_index2 = -1;
  for (int i = 0; i < (n); ++i) {
    if (i == 0) continue;
    if (s[i] != '0') {
      non_zero_index1 = i;
      f1 = s[i] - '0';
      break;
    }
  }
  if (non_zero_index1 > 0)
    for (int i = non_zero_index1 + 1; i < n; i++) {
      if (s[i] != '0') {
        non_zero_index2 = i;
        f2 = s[i] - '0';
        break;
      }
    }
  if (k == 1) {
    ans += f0;
  } else if (k == 2) {
    long long now1 = 0;
    if (non_zero_index1 > 0) now1 += f1;
    if (non_zero_index1 > 0 && non_zero_index1 < n - 1)
      now1 += (n - non_zero_index1 - 1) * 9;
    long long now2 = f0 - 1;
    now2 *= (n - 1) * 9;
    ans += now1 + now2;
  } else if (k == 3) {
    long long now1 = 0, now2 = 0, now3 = 0, now4 = 0;
    if (non_zero_index2 > 0) now1 = f1 * f2;
    if (non_zero_index2 > 0 && non_zero_index2 < n - 1)
      now2 = f1 * (n - non_zero_index2 - 1) * 9;
    if (non_zero_index1 > 0 && non_zero_index1 < n - 2)
      now3 = comb((n - non_zero_index1 - 1), 2) * 9 * 9;
    now4 = f0 - 1;
    now4 *= comb((n - 1), 2) * 9 * 9;
    ans += now1 + now2 + now3 + now4;
  }
  cout << ans << endl;
  return 0;
}
