#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 67280421310721;
const long long int INF = (long long int)1e15;
long long int cmb(long long int n, long long int r) {
  if (n == 0 || n < r) return 0;
  long long int t = 1, m = 1;
  for (long long int(i) = (0); (i) < (r); ++(i)) {
    t *= (n - i);
    m *= (i + 1);
  }
  return t / m;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  long long int K;
  cin >> S >> K;
  long long int ans = 0;
  long long int N = S.length();
  long long int n = 0;
  for (long long int(i) = (0); (i) < (N); ++(i)) {
    if (S[i] > '0') n++;
  }
  if (K == n) ans++;
  for (long long int(i) = (0); (i) < (N); ++(i)) {
    if (S[i] == '0') continue;
    ans += cmb(N - 1 - i, K) * pow(9, K);
    ans += cmb(N - 1 - i, K - 1) * pow(9, K - 1) * std::max(S[i] - '1', 0);
    K--;
  }
  cout << ans << endl;
  return 0;
}
