#include <bits/stdc++.h>
using namespace std;
int c(int k, int n) {
  if (k == 0 || k == n) return 1;
  return c(k - 1, n - 1) + c(k, n - 1);
}
signed main() {
  ios_base::sync_with_stdio();
  cin.tie(0);
  cout.tie(0);
  ;
  string str;
  cin >> str;
  int k;
  cin >> k;
  int n = str.length();
  int ans = 0;
  for (int i = k; i <= n - 1; i++) ans += 9 * c(k - 1, i - 1) * pow(9, k - 1);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if ((str[i] - '0') != 0) {
      cnt++;
      ans += (str[i] - '0' - 1) * c(k - cnt, n - cnt) * pow(9, k - cnt);
    }
  }
  if (cnt == k) ans++;
  cout << ans;
}
