#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
const int ARRAY = 150;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
const int MOD = 1e9 + 7;
ll N = 0;
ll K = 0;
ll t;
ll ret = 0;
string s;
ll fact[ARRAY];
ll inv_fact[ARRAY];
ll inv[ARRAY];
void combiInit() {
  fact[0] = fact[1] = 1;
  inv_fact[0] = inv_fact[1] = 1;
  inv[1] = 1;
  for (int i = (2); i < (ARRAY); i++) {
    fact[i] = fact[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    inv_fact[i] = inv_fact[i - 1] * inv[i] % MOD;
  }
}
ll combi(ll n, ll r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fact[n] * (inv_fact[r] * inv_fact[n - r] % MOD) % MOD;
}
ll g(ll i, ll j) {
  if (j < 0) return 0;
  if (N - i + 1 < 0) return 0;
  if (N - i + 1 < j) return 0;
  if (j == 0) return 1;
  ll acc = 1;
  for (int _ = 0; _ < (j); _++) acc *= 9;
  return combi(N - i + 1, j) * acc;
}
ll f(ll i, ll j) {
  if (j < 0) return 0;
  if (N - i + 1 < 0) return 0;
  if (N - i + 1 < j) return 0;
  if (j == 0) return 1;
  ll sum = 0;
  ll nz = s[i] - '0';
  sum += g(i + 1, j);
  if (s[i] == 0) return sum;
  sum += (nz - 1) * g(i + 1, j - 1);
  sum += f(i + 1, j - 1);
  return sum;
}
void input() {
  cin >> s;
  cin >> K;
}
void solve() {
  combiInit();
  N = s.length();
  s = '0' + s;
  ret = f(1, K);
  cout << (ret) << endl;
}
int main(void) {
  input();
  solve();
}
