#include <bits/stdc++.h>
using namespace std;
void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
long long nCr(long long n, long long r) {
  long long ret = 1;
  for (int i = n - r + 1; i <= n; ++i) ret *= i;
  for (int i = 2; i <= r; ++i) ret /= i;
  return ret;
}
void solve() {
  string n;
  cin >> n;
  int k;
  cin >> k;
  if (k > n.size()) {
    puts("0");
    return;
  }
  long long ans = nCr(n.size() - 1, k) * pow(9, k);
  int skipped = 1;
  for (int i = 1; i <= k && i <= n.size(); ++i) {
    long long cur = n[i - 1] - '0' - 1;
    cur *= nCr(n.size() - i - skipped + 1, k - i) * pow(9, k - i);
    ans += cur;
    if (n[i + skipped - 1] == '0') {
      for (int j = i + skipped; j < (int)n.size(); ++j) {
        if (n[j] != '0') break;
        ++skipped;
      }
    }
    ans += nCr(n.size() - i - skipped, k - i) * pow(9, k - i);
  }
  cout << ans;
}
int main() {
  init();
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
