#include <bits/stdc++.h>
using namespace std;
const long long inf = 10e17;
const long long mod = inf;
const long double eps = 10e-9;
long long solve(void);
long long gcd(long long x, long long y);
int main(void) {
  while (solve()) {
  }
  return 0;
}
long long mulmod(long long x, long long y) { return (x * y) % mod; }
long long submod(long long x, long long y) { return (x - y + 100 * mod) % mod; }
long long power(long long n, long long r) {
  if (r == 0) {
    return 1;
  }
  if (r == 1) {
    return n;
  }
  if (n == 0) {
    return 0;
  }
  if (n == 1) {
    return 1;
  }
  if (r % 2 == 0) {
    long long y = power(n, r / 2);
    return mulmod(y, y);
  } else {
    long long y = power(n, (r - 1) / 2);
    return n * mulmod(y, y) % mod;
  }
}
long long gcd(long long x, long long y) {
  if (y == 1) {
    return 1;
  }
  if (x % y == 0) {
    return y;
  }
  return gcd(y, x % y);
}
vector<long long> perm;
vector<long long> inv;
void init_inv(long long m) {
  perm.resize(m);
  inv.resize(m);
  perm[0] = 1;
  inv[0] = 1;
  for (long long i = 1; i < m; i++) {
    perm[i] = mulmod(perm[i - 1], i);
  }
  for (long long i = 1; i < m; i++) {
    inv[i] = power(perm[i], mod - 2);
  }
}
long long ncr(long long n, long long r) {
  if (r == n || r == 0) {
    return 1;
  }
  long long ans = 1;
  long long p = 1;
  for (long long i = n - r + 1; i <= n; i++) p *= i;
  return p / (perm[r]);
}
bool binary_check(long long mid, long long key) { return mid >= key; }
long long binary_search() {
  long long n, k;
  cin >> n >> k;
  long long ng = 0;
  long long ok = n;
  while (abs(ok - ng) > 1) {
    long long mid = (ok + ng) / 2;
    if (binary_check(mid, k))
      ok = mid;
    else
      ng = mid;
  }
  return ok;
}
string s;
long long k, l;
long long calc(long long digit, long long k, bool smaller) {
  if (k == 0) {
    return 1;
  }
  if (l - digit == k) {
    (k == 0) ? 1 : 0;
  }
  if (l - digit < k) {
    return 0;
  }
  if (smaller) {
    return ncr(l - digit, k) * power(9, k);
  }
  long long zero = calc(digit + 1, k, true);
  long long bet = calc(digit + 1, k - 1, true) * (s[digit] - 1 - '0');
  long long giri = calc(digit + 1, k - 1, false);
  return zero + bet + giri;
}
long long solve(void) {
  init_inv(1000);
  cin >> s;
  cin >> k;
  l = s.length();
  cout << calc(0, k, false) << endl;
  return 0;
}
