#include <bits/stdc++.h>
using namespace std;
const int N = 105;
string s;
long long ans = 0, cheng;
int n, k, c[N];
vector<int> v;
long long dfs(int now, int cnt, bool f) {
  if (cnt == k) return 1;
  if (now >= n) return 0;
  if (f) {
    long long res = 0;
    for (int i = now; i < n; i++) {
      res += dfs(i + 1, cnt + 1, f);
    }
    return res * 9;
  } else {
    long long res = 0;
    if (cnt + 1 != k)
      res = dfs(v[cnt + 1], cnt + 1, f);
    else
      res = 1;
    res += dfs(v[cnt] + 1, cnt, !f);
    res += dfs(v[cnt] + 1, cnt + 1, !f) * (s[now] - '0' - 1);
    return res;
  }
}
int main() {
  cin >> s >> k;
  n = s.size();
  if (s == "0") {
    cout << "0\n";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (s[i] != '0') {
      v.push_back(i);
    }
  }
  while (v.size() < k) v.push_back(v[v.size() - 1] + 1);
  if (v[v.size() - 1] + 1 > s.size()) {
    puts("0");
    return 0;
  }
  cout << dfs(v[0], 0, 0) << endl;
  return 0;
}
