#include <bits/stdc++.h>
using namespace std;
const int M = 120000;
int m, k;
string n;
int C(int a, int b) {
  int ret = 1;
  for (int i = (0); i <= (b - 1); ++i) ret = ret * (a - i);
  for (int i = (1); i <= (b); ++i) ret /= i;
  return ret;
}
int dfs(int u, int k, int limit) {
  if (k < 0) return 0;
  if (u == m && k == 0) return 1;
  if (!limit) {
    int ret = C(m - u, k);
    for (int i = (1); i <= (k); ++i) ret *= 9;
    return ret;
  }
  if (n[u] == '0') return dfs(u + 1, k, limit);
  int ret = dfs(u + 1, k - 1, limit);
  ret += dfs(u + 1, k - 1, 0) * (n[u] - '1');
  ret += dfs(u + 1, k, 0);
  return ret;
}
int main() {
  cin >> n >> k;
  m = n.size();
  cout << dfs(0, k, 1) << endl;
  return 0;
}
