#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int ret = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  for (; ch >= '0' && ch <= '9'; ch = getchar()) ret = ret * 10 + ch - '0';
  return ret * f;
}
const int INF = 1 << 30;
const int maxn = 100 + 10;
int a[maxn], k, n;
char s[maxn];
long long Pow(long long x, int p) {
  long long ret = 1;
  for (int i = 1; i <= p; ++i) ret *= x;
  return ret;
}
long long C(int n, int m) {
  if (n < 0 || m < 0 || n < m) return 0;
  long long ret = 1;
  for (int i = 0; i <= m - 1; ++i) ret *= (n - i);
  for (int i = 1; i <= m; ++i) ret /= i;
  return ret;
}
int main() {
  scanf("%s%d", s + 1, &k);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) a[i] = s[i] - '0';
  for (int i = 1; i <= n / 2; ++i) swap(a[i], a[n + 1 - i]);
  long long ans = C(n - 1, k) * Pow(9, k);
  int p1 = n - 1, p2;
  while (p1 >= 1 && a[p1] == 0) --p1;
  p2 = p1 - 1;
  while (p2 >= 1 && a[p2] == 0) --p2;
  if (k == 1) {
    ans += (a[n]);
  }
  if (k == 2) {
    ans += (a[n] - 1) * C(n - 1, k - 1) * Pow(9, k - 1);
    if (p1 > 0) ans += 1 * C(p1 - 1, k - 1) * Pow(9, k - 1);
    if (p1 > 0) ans += (a[p1]);
  }
  if (k == 3) {
    ans += (a[n] - 1) * C(n - 1, k - 1) * Pow(9, k - 1);
    if (p1 > 0) ans += 1 * C(n - 2, k - 1) * Pow(9, k - 1);
    if (p1 > 0) ans += (a[p1] - 1) * (p1 - 1) * 9;
    if (p2 > 0) ans += 1 * 1 * (p2 - 1) * 9;
    if (p2 > 0) ans += (a[p2]);
  }
  cout << ans << endl;
  return 0;
}
