#include <bits/stdc++.h>
using namespace std;
string s;
long long k;
long long ans;
long long f(long long p, long long q) {
  if (q == 0) return 1;
  if (p >= s.size()) return 0;
  if (s[p] == 0) return f(p + 1, q);
  long long re = 0;
  re += f(p + 1, q - 1);
  long long x = 1;
  for (long long i = 0; i < q; i++) x *= 9;
  long long lt = s.size() - p - 1;
  if (q == 1)
    re += lt * x + (s[p] - '1') * x / 9;
  else if (q == 2)
    re += lt * (lt - 1) / 2 * x + (s[p] - '1') * lt * x / 9;
  else
    re += lt * (lt - 1) * (lt - 2) / 6 * x +
          (s[p] - '1') * lt * (lt - 1) / 2 * x / 9;
  return re;
}
int main() {
  cin >> s >> k;
  cout << f(0, k);
  return 0;
}
