#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9 + 100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll modinv(ll x) { return modpow(x, mod - 2); }
ll comb(ll n, ll k) {
  ll ans1 = 1;
  ll ans2 = 1;
  for (int i = (0); i < (k); i++) ans1 = ans1 * (n - i) % mod;
  for (int i = (0); i < (k); i++) ans2 = ans2 * (i + 1) % mod;
  return ans1 * modinv(ans2) % mod;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  string s;
  cin >> s;
  ll k;
  cin >> k;
  if (s.size() < 5) {
    ll n = stoi(s);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      int tmp = i;
      int flag = 0;
      while (1) {
        if (tmp % 10 != 0) flag++;
        tmp /= 10;
        if (tmp == 0) break;
      }
      if (flag == k) ans++;
    }
    cout << ans << endl;
    return 0;
  }
  ll count = s.size();
  int first = s[0] - '0';
  int second = s[1] - '0';
  int third = s[2] - '0';
  ll ans = pow(9, k) * comb(count, k);
  if (k == 1) {
    ans -= (9 - first);
  }
  if (k == 2) {
    ans -= (9 - first) * 1 * 9 * (count - 1);
    ans -= (9 - second);
  }
  if (k == 3) {
    ans -= (9 - first) * comb(count - 1, 2) * 9 * 9;
    ans -= (9 - second) * 9 * (count - 2);
    ans -= (9 - third);
  }
  cout << ans << endl;
  return 0;
}
