#include <bits/stdc++.h>
using namespace std;
const int64_t INF = (1LL << 62);
const double inf = pow(10, 10);
const long double pi = acosl(1);
const int64_t mod = 1000000007;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int ddx[8] = {1, 0, -1, -1, -1, 0, 1, 1};
const int ddy[8] = {1, 1, 1, 0, -1, -1, -1, 0};
template <typename T>
T binomial(int64_t N, int64_t K) {
  if (K < 0 || N < K) return 0;
  T ret = 1;
  for (T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
int64_t func(string s, int64_t k) {
  if (k == 0) return 1;
  int64_t ret = 0;
  int64_t n = s.size();
  int64_t d = (s[0] - '0');
  string s2;
  for (int i = 1; i < n; i++) s2.push_back(s[i]);
  if (d == 0) {
    return func(s2, k);
  } else {
    ret += binomial<int64_t>(n - 1, k) * pow(9, k);
    ret += (d - 1) * binomial<int64_t>(n - 1, k - 1) * pow(9, k - 1);
    ret += func(s2, k - 1);
  }
  return ret;
}
int main() {
  string n;
  int64_t k;
  cin >> n >> k;
  cout << func(n, k) << endl;
}
