#include <bits/stdc++.h>
using namespace std;
int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long C(long long a, long long b) {
  double ans = 1;
  for (int i = 1; i <= a; i++) {
    ans *= b;
    b--;
    ans /= i;
  }
  return (floor(ans + 0.5));
}
int main() {
  int a[105], k;
  char A[105];
  cin >> A;
  int n = strlen(A);
  cin >> k;
  for (int i = 0; i < n; i++) {
    a[i] = A[i] - '0' + 1;
  }
  if (k == 1) {
    long long ans = 9 * (n - 1);
    ans += a[0] - 1;
    cout << ans << endl;
  } else if (k == 2) {
    long long t = C(k, n - 1);
    long long ans = 9 * 9 * t;
    for (int i = 1; i < a[0] - 1; i++) ans += 9 * (n - 1);
    for (int i = 1; i < n; i++) {
      ans += a[i] - 1;
    }
    cout << ans << endl;
  }
  return 0;
}
