#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
const long long INF = 100000000000010000;
void test() { cout << "888888888888888888888888" << endl; }
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long pow_mod(long long x, long long k) {
  x %= mod;
  long long res = 1;
  while (k > 0) {
    if (k % 2) {
      res *= x;
      res %= mod;
    }
    x *= x;
    x %= mod;
    k /= 2;
  }
  return res;
}
long long div_mod(long long x) { return pow_mod(x, mod - 2); }
const int MAXcomb = 200010;
long long fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAXcomb; 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 comb(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * finv[k] % mod * finv[n - k] % mod;
}
string N;
long long K;
long long ans;
long long co[4][4];
long long ct;
long long com(long long x, long long y) {
  if (x < y) return 0;
  long long res = 1;
  for (long long i = 0; i < (y); i++) {
    res *= x - i;
  }
  for (long long i = 0; i < (y); i++) {
    res /= i + 1;
  }
  return res;
}
void solve() {
  cin >> N >> K;
  long long len = N.length();
  co[0][0] = 1;
  co[1][0] = 1, co[1][1] = 1;
  co[2][0] = 1, co[2][1] = 2, co[2][2] = 1;
  co[3][0] = 1, co[3][1] = 3, co[3][2] = 3, co[3][3] = 1;
  for (long long i = 0; i < (N.length()); i++) {
    if (N[i] == '0') continue;
    if (K >= 0) {
      ans += com(len - i - 1, K) * pow(9, K);
    }
    if (K - 1 >= 0) {
      ans += com(len - i - 1, K - 1) * pow(9, K - 1) * (N[i] - '1');
    }
    K -= 1;
    if (K < 0) break;
  }
  if (K >= 0) {
    ans++;
  }
  cout << ans << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  long long N;
  cin >> N;
}
