#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
int main() {
  int K, H, W, B, flag = 0, i, j, k, l, ans_0 = 0, ans_W = 0, len, max_i = 0;
  int A[200000];
  int temp, max = 0;
  double sum = 0.0;
  char N[100];
  long long dp[101][4][2];
  scanf("%s %d", N, &K);
  len = strlen(N);
  dp[0][0][0] = 1;
  for (i = 0; i < len; i++) {
    int temp = N[i] - '0';
    for (j = 0; j <= K; j++) {
      for (k = 0; k < 2; k++) {
        for (l = 0; l < 10; l++) {
          int ni = i + 1, nj = j, nk = k;
          if (l != 0) nj++;
          if (nj > K) continue;
          if (k == 0) {
            if (l > temp) continue;
            if (l < temp) nk = 1;
          }
          dp[ni][nj][nk] += dp[i][j][k];
        }
      }
    }
  }
  int ans = dp[len][K][0] + dp[len][K][1];
  printf("%lld\n", ans);
  return 0;
}
