#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll power(ll x, ll y);
const ll MOD = 1000000007;
ll ncr(ll n, ll r) {
  if (n < r) return 0ll;
  ll res = 1;
  for (int i = 0; i < r; i++) res *= (n - i);
  for (int i = 2; i <= r; i++) res /= i;
  return res;
}
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int k;
  cin >> k;
  s += '0';
  ll x = n, y = n;
  for (int i = 1; i < n; i++)
    if (s[i] != '0') {
      x = i;
      break;
    }
  for (int i = x + 1; i < n; i++)
    if (s[i] != '0') {
      y = i;
      break;
    }
  ll res = ncr(n, k);
  for (int i = 0; i < k; i++) res *= 9;
  if (k == 1) res -= (9 - s[0] + '0');
  if (k == 2) {
    if (x == n)
      res -= (10 - s[0] + '0') * (n - 1) * 9;
    else
      res -= (9 - s[x] + '0'), res -= (x - 1) * 9,
          res -= (9 - s[0] + '0') * (n - 1) * 9;
  }
  if (n == 3) {
    res = 0;
    for (int i = 2; i < n - 1; i++) res += (i * (i - 1)) / 2 * 9 * 9 * 9;
    res += max(0, (s[0] - '0' - 1) * (n - 1) * (n - 2) / 2 * 9 * 9);
    for (int i = 1; i < n; i++) {
      if (s[i] != '0') {
        res += max(0, (s[i] - '0' - 1) * (n - i - 1) * 9);
        res += max(0, (n - i - 1) * (n - i - 2) / 2 * 9 * 9);
        for (int j = i + 1; j < n; j++) {
          if (s[j] != '0') {
            res += s[j] - '0';
            res += max(0, (n - j - 1) * 9);
            break;
          }
        }
        break;
      }
    }
  }
  cout << res;
}
ll power(ll x, ll y) {
  ll res = 1;
  x %= MOD;
  while (y > 0) {
    if (y & 1) res = (res * x) % MOD;
    y = y >> 1, x = (x * x) % MOD;
  }
  return res;
}
