#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int ret = 0, t = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') t = -1, c = getchar();
  while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
  return ret * t;
}
char a[101] = {};
int k;
int dp[101][11] = {};
int main() {
  scanf("%s", a + 1);
  k = read();
  int len = strlen(a + 1);
  int i, j;
  dp[0][0] = 1;
  dp[1][0] = 1;
  dp[1][1] = 9;
  for (i = 2; i <= len; i++)
    for (j = 0; j <= 3; j++) {
      dp[i][j] = dp[i - 1][j];
      if (j != 0) dp[i][j] += dp[i - 1][j - 1] * 9;
    }
  int ans = 0;
  for (i = 1; i <= len; i++) {
    if (k >= 1) ans += (a[i] - '0' - (i == len ? 0 : 1)) * dp[len - i][k - 1];
    if (k >= 0) ans += dp[len - i][k];
    k--;
  }
  printf("%d\n", ans);
  return 0;
}
