#include <bits/stdc++.h>
using namespace std;
vector<long long int> v;
long long int l, k;
long long int f(long long int d, long long int c, bool m) {
  if (l == d) {
    return c == 0;
  }
  long long int s = f(d + 1, c, m && v[d] == 0);
  if (c == 0) {
    return s;
  }
  if (m) {
    if (v[d] == 0) {
      return s;
    }
    return s + (v[d] - 1) * f(d + 1, c - 1, false) + f(d + 1, c - 1, true);
  } else {
    return s + 9 * f(d + 1, c - 1, false);
  }
}
int main(void) {
  string n;
  cin >> n >> k;
  l = n.length();
  v = vector<long long int>(l);
  for (long long int i = 0; i < l; i++) {
    v[i] = n.c_str()[i] - '0';
  }
  cout << f(0, k, true) << "\n";
}
