#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 res = ncr(n, k);
  for (int i = 0; i < k; i++) res *= 9;
  if (k == 1) res -= (9 - s[0] + '0');
  if (k == 2) {
    ll x = n;
    for (int i = n - 1; i >= 1; i--)
      if (s[i] != '0') x = i;
    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 (k == 3) {
    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;
      }
    if (x == n && y == n) res -= (10 - s[0] + '0') * (n - 1) * (n - 2) * 9 * 9;
    if (x < n && y == n)
      res -= (10 - s[x] + '0') * (n - 2) * 9,
          res -= (9 - s[0] + '0') * (n - 1) * (n - 2) * 81;
    if (x < n && y < n)
      res -= (9 - s[y] + '0'), res -= (y - x - 1) * 9,
          res -= (9 - s[x] + '0') * (n - x - 1) * 9,
          res -= (x - 1) * 9 * (n - x - 1) * 9,
          res -= (9 - s[0] + '0') * (n - 2) * (n - 1) * 9 * 9;
  }
  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;
}
