#include <bits/stdc++.h>
using namespace std;
int main() {
  string ns;
  int k;
  cin >> ns;
  cin >> k;
  vector<int> n;
  for (int i = 0; i < (ns.size()); ++i) n.push_back(ns[i] - '0');
  int keta = n.size();
  map<pair<int, int>, int> mp;
  mp[pair<int, int>{0, 0}] = 1;
  mp[pair<int, int>{1, 1}] = 1;
  if (n[0] > 1) {
    mp[pair<int, int>{1, 0}] = n[0] - 1;
  }
  for (int kn = 1; kn < keta; kn++) {
    map<pair<int, int>, int> new_mp;
    for (int ic = 0; ic <= k; ic++)
      for (int b = 0; b <= 1; b++) {
        int num = mp[pair<int, int>{ic, b}];
        if (ic > k || num == 0) continue;
        if (b) {
          new_mp[pair<int, int>{ic, 0}] += num;
          if (n[kn]) {
            new_mp[pair<int, int>{ic + 1, 1}] += num;
          }
          if (n[kn] > 1) {
            new_mp[pair<int, int>{ic + 1, 0}] += num * (n[kn] - 1);
          }
        } else {
          new_mp[pair<int, int>{ic + 1, 0}] += num * 9;
          new_mp[pair<int, int>{ic, 0}] += num;
        }
      }
    mp = new_mp;
  }
  long long ans = mp[pair<int, int>{k, 0}] + mp[pair<int, int>{k, 1}];
  cout << ans << endl;
  return 0;
}
