#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug &operator<<(const c &) {
    return *this;
  }
};
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) {
  int res = 0;
  while (n && ++res) n -= n & (-n);
  return res;
}
const double pi = acos(-1);
int cmp(double x, double y = 0, double tol = 1e-9) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
int main() {
  string s;
  cin >> s;
  int k;
  scanf("%d", &k);
  int n = int((s).size());
  string t(n - 1, '0');
  for (int i = 0; i < int(k - 1); i++) t[n - 2 - i] = '1';
  int cnt = 0;
  vector<int> C;
  int start;
  if (k == 1)
    start = 1;
  else
    start = pow(10, k - 1) + 1;
  for (int i = start; i < pow(10, k); i++) {
    int pair<int, int> = i;
    bool flag = true;
    while (pair<int, int>) {
      if ((pair<int, int> % 10) == 0) flag = false;
      pair<int, int> /= 10;
    }
    if (flag) cnt++;
    if (flag) C.push_back(i);
  }
  long long mul = 1, den = 1;
  for (int i = 0; i < int(k); i++) {
    mul *= (n - 1 - i);
    den *= (i + 1);
  }
  long long ans = 1ll * (mul / den) * cnt;
  do {
    vector<int> p;
    p.push_back(0);
    for (int i = 0; i < int(n - 1); i++)
      if (t[i] == '1') p.push_back(i + 1);
    string t1 = "1" + t;
    vector<int> d(k);
    for (int i : C) {
      int pair<int, int> = i;
      for (int j = 0; j < int(k); j++) {
        d[k - 1 - j] = pair<int, int> % 10;
        pair<int, int> /= 10;
      }
      for (int j = 0; j < int(k); j++) t1[p[j]] = '0' + d[j];
      if (t1 <= s) ans++;
    }
  } while (next_permutation((t).begin(), (t).end()));
  printf("%lld\n", ans);
  return 0;
}
