#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int32_t main() {
  string s;
  cin >> s;
  long long k;
  cin >> k;
  long long n = s.size();
  string t(n - 1, '0');
  for (long long i = 0; i < k - 1; i++) t[n - 2 - i] = '1';
  int cnt = 0;
  std::vector<long long> C;
  for (long long i = pow(10, k - 1) + 1; i < pow(10, k); i++) {
    int ii = i;
    bool ok = true;
    while (ii) {
      if ((ii % 10) == 0) ok = false;
      ii /= 10;
    }
    if (ok) cnt++;
    if (ok) C.push_back(i);
  }
  long long mul = 1, den = 1;
  for (long long i = 0; i < k; i++) {
    mul *= (n - 1 - i);
    den *= (i + 1);
  }
  long long ans = 1ll * (mul / den) * cnt;
  do {
    std::vector<int> p;
    p.push_back(0);
    for (long long i = 0; i < n - 1; i++)
      if (t[i] == '1') p.push_back(i + 1);
    string t1 = "1" + t;
    std::vector<int> d(k);
    for (int i : C) {
      int ii = i;
      for (long long j = 0; j < k; j++) {
        d[k - 1 - j] = ii % 10;
        ii /= 10;
      }
      for (long long j = 0; j < k; j++) t1[p[j]] = '0' + d[j];
      if (t1 <= s) ans++;
    }
  } while (next_permutation((t).begin(), (t).end()));
  cout << ans;
  return 0;
}
