#include <bits/stdc++.h>
using namespace std;
long long C(int n, int r) {
  if (r > n - r) r = n - r;
  long long ans = 1;
  int i;
  for (i = 1; i <= r; i++) {
    ans *= n - r + i;
    ans /= i;
  }
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string n;
  int k;
  cin >> n >> k;
  int d = n.size();
  if (d < k) {
    cout << 0 << endl;
    return 0;
  }
  long long ans = 0;
  ans += (long long)pow(9, k) * C(d - 1, k);
  int m = stoi(string(1, n[0]));
  if (d >= 3) {
    ans += (long long)m * pow(9, k - 1) * C(d - 2, k - 1);
  }
  if (k >= 2) {
    if (d >= 1) {
      int mm = stoi(string(1, n[1]));
      long long s = (long long)9 * (m - 1) + mm;
      if (k == 2)
        ans += s;
      else if (k >= 3) {
        int mmm = stoi(string(1, n[2]));
        ans += (long long)s * (9 * (d - 3) + mmm);
      }
    }
  }
  cout << ans << endl;
}
