#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
template <class T>
using vt = vector<T>;
template <class T>
using vvt = vector<vector<T>>;
long long gcd(long long n, long long m) { return (m == 0 ? n : gcd(m, n % m)); }
long long lcm(long long n, long long m) { return (n / gcd(n, m) * m); }
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int sz = 300;
long long fac[sz], finv[sz], inv[sz];
void init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (long long i = 2; i < sz; ++i) {
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}
long long get(int n, int k) {
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int k;
  cin >> s >> k;
  if (k == 2 && s.size() < 2) return cout << 0 << endl, 0;
  if (k == 3 && s.size() < 3) return cout << 0 << endl, 0;
  init();
  long long ans = 0;
  int n = s.size();
  for (int i = k; i < n; ++i) {
    if (k == 1)
      ans += 9;
    else if (k == 2)
      ans += 9 * 9 * (i - 1);
    else if (k == 3)
      ans += 9 * 9 * 9 * get(i - 1, 2);
  }
  int num = s[0] - '0';
  if (k == 1) {
    ans += num;
  } else if (k == 2) {
    ans += (num - 1) * 9 * (n - 1);
    int i = 1;
    while (i < n && s[i] == '0') ++i;
    if (i < n) ans += s[i] - '0';
    if (i + 1 < n) ans += 9 * (n - i - 1);
  } else if (k == 3) {
    ans += (num - 1) * 9 * 9 * get(n - 1, 2);
    int i = 1;
    while (i < n && s[i] == '0') ++i;
    if (i + 1 < n) ans += ((s[i] - '0') - 1) * 9 * (n - i - 1);
    int j = i + 1;
    while (j < n && s[j] == '0') ++j;
    if (j < n) ans += s[j] - '0';
    if (j + 1) ans += 9 * (n - j - 1);
    if (n - i - 1 >= 2) ans += 9 * 9 * get(n - i - 1, 2);
  }
  cout << ans << endl;
}
