#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7 + (1e+9);
ll big = 1e9 + 7;
ll ff = 0;
vector<ll> p(10000, 1);
vector<ll> ip(10000, 1);
ll pow_ans(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res *= x;
      res %= big;
    }
    x *= x;
    x %= big;
    n >>= 1;
  }
  return res;
}
void initialize() {
  for (int i = 1; i < 10000; i++) {
    p[i] = p[i - 1] * i % big;
  }
  for (int i = 1; i < 10000; i++) {
    ip[i] = pow_ans(p[i], big - 2);
  }
}
ll nPk(int i, int j) {
  if (ff == 0) {
    initialize();
    ff = 1;
  }
  if (i < 0 || j < 0 || i < j)
    return 0;
  else {
    ll tem;
    tem = p[i] * ip[i - j] % big;
    return tem;
  }
}
ll nCk(int i, int j) {
  if (ff == 0) {
    initialize();
    ff = 1;
  }
  if (i < 0 || j < 0 || i < j) return 0;
  ll tmp = nPk(i, j);
  tmp = tmp * ip[j] % big;
  return tmp;
}
int main() {
  ll n, k, ans = 0;
  string s;
  cin >> s >> k;
  n = s.size();
  ll i;
  for (ll j = 0; j < 3 && k > 0; j++) {
    for (i = 1; i < n - j; i++) {
      if (i < k) continue;
      ans += 9 * nCk(i - 1, k - 1) * pow_ans(9, k - 1);
    }
    if (!(i < k))
      ans += (s[j] - '0' - 1) * nCk(i - 1, k - 1) * pow_ans(9, k - 1);
    k--;
  }
  ans++;
  cout << ans << endl;
}
