#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcd(long long a, long long b) {
  if (b == 0) return a;
  return (a / gcd(a, b)) * b;
}
vector<int> calc(long long num) {
  int dig;
  vector<int> p;
  while (num) {
    dig = num % 10;
    p.push_back(dig);
    num /= 10;
  }
  return p;
}
string N;
long long K;
int main() {
  cin >> N;
  cin >> K;
  long long keta = N.size();
  long long comb = 1;
  long long check = 0;
  if (keta == 3) {
    check += (N[0] - 48) * 100;
    check += (N[1] - 48) * 10;
    check += (N[2] - 48);
    if (check <= 110 && K >= 3) {
      cout << 0 << endl;
      return 0;
    }
  } else if (keta == 2) {
    check += (N[0] - 48) * 10;
    check += (N[1] - 48);
    if (check <= 10 && K >= 2) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (keta < K) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < K; i++) {
    comb *= long long(keta - i);
  }
  for (int i = 0; i < K; i++) {
    comb /= long long(K - i);
    comb *= long long(9);
  }
  if (K == 1) {
    comb -= long long(9 - (N[0] - 48));
  } else if (K == 2) {
    comb -= long long(keta - 1) * long long(9) * long long(9 - (N[0] - 48));
    comb -= long long(9 - (N[1] - 48));
  } else if (K == 3) {
    comb -= long long(9 - (N[0] - 48)) * (long long)81 * long long(keta - 1) *
            long long(keta - 2) / (long long)2;
    comb -= long long(9 - (N[1] - 48)) * (long long)9 * long long(keta - 2);
    comb -= long long(9 - (N[2] - 48));
  }
  cout << max(comb, long long(0)) << endl;
}
