#include <bits/stdc++.h>
using namespace std;
const int S_MAX = 100;
const int K_MAX = 3;
char S[S_MAX + 1];
int N, K;
int dp[S_MAX + 1][K_MAX + 1];
int f(int i, int j) {
  int ret = 1;
  int a = i;
  int b = 1;
  for (int k = 0; k < (int)(j); k++) {
    ret *= 9;
    ret *= a;
    ret /= b;
    a--;
    b++;
  }
  return ret;
}
void solve() {
  N = strlen(S);
  dp[0][0] = 1;
  dp[0][1] = S[N - 1] - '0';
  for (int i = (1); i <= (int)(N - 1); i++) {
    int v = S[N - 1 - i] - '0';
    dp[i][0] = 1;
    for (int j = (1); j <= (int)(K); j++) {
      dp[i][j] = f(i, j);
      if (v > 0) {
        dp[i][j] += f(i, j - 1) * (v - 1);
        dp[i][j] += dp[i - 1][j - 1];
      }
    }
  }
  printf("%d\n", dp[N - 1][K]);
}
void input() {
  scanf("%s", S);
  scanf("%d", &K);
}
int main() {
  input();
  solve();
  return 0;
}
