#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int nmax = 150;
int c[nmax][nmax];
template <typename T>
T C(T x, T y) {
  if (c[x][y] > 0) return c[x][y];
  if (y == 0 || x == y) return 1;
  if (c[x][y]) return c[x][y];
  return c[x][y] = C(x - 1, y - 1) + C(x - 1, y);
}
int main() {
  string s;
  ll k;
  cin >> s >> k;
  ll n = s.size();
  if (n < k) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = C(n, k) * pow(9, k);
  vector<ll> t;
  for (ll i = 0; i < k; ++i) t.push_back(s[i] - '0');
  ans -= (9 - t[0]) * C(n - 1, k - 1) * pow(9, k - 1);
  if (k > 1) {
    ans -= (9 - t[1]) * C(n - 2, k - 2) * pow(9, k - 2);
  }
  if (k > 2) {
    ans -= (9 - t[2]) * C(n - 3, k - 3) * pow(9, k - 3);
  }
  cout << ans << endl;
}
