#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll chose(int n, int r) {
  ll a = 1, b = 1;
  for (int i = 0; i < (int)(r); i++) {
    a *= n - i;
    b *= r - i;
  }
  return a / b;
}
int main() {
  string N;
  int K;
  cin >> N >> K;
  int n = N.size();
  ll ans = 0;
  ans = chose(n - 1, K) * pow(9, K);
  int s = 0;
  int e = 0;
  for (int i = 0; i < (int)(K); i++) {
    s = pow(10, i);
    e = 10 * e + (N[i] - '0');
  }
  for (int i = s; i <= e; i++) {
    int a = i;
    int c = 0;
    while (a > 0) {
      int b = a % 10;
      a /= 10;
      if (b != 0) c++;
    }
    ans += chose(n - K, K - c) * pow(9, K - c);
  }
  cout << ans << endl;
}
