#include <bits/stdc++.h>
using namespace std;
int conbi[100][100];
void conbimemo(int n, int r) {
  int i, j;
  for (i = 0; i <= n; i++) {
    conbi[i][0] = 1;
  }
  for (j = 1; j <= n; j++) {
    conbi[j][1] = j;
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= r; j++) {
      conbi[i][j] = conbi[i - 1][j - 1] + conbi[i - 1][j];
    }
  }
}
int keta(double n) {
  int tmp = 0;
  if (n == 0) {
    tmp = 1;
  } else {
    while (n > 0) {
      n = floor(n / 10);
      tmp++;
    }
  }
  return tmp;
}
int main() {
  string n;
  int k;
  cin >> n >> k;
  int l = n.length();
  int64_t sum = 0;
  conbimemo(100, 100);
  for (int i = 0; l - i - 1 >= 0; i++) {
    if (l - i - k < 0) {
      break;
    }
    if (i == 0) {
      sum += (pow(9, k - 1) * (n[0] - '0')) * conbi[l - 1][l - k];
    } else {
      sum += pow(9, k) * conbi[l - i - 1][l - i - k];
    }
  }
  cout << sum << endl;
}
