#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int K;
  cin >> K;
  long long dp[105][4];
  memset(dp, 0, sizeof(dp));
  dp[1][1] = 9;
  dp[2][1] = dp[1][1] + 9;
  dp[2][2] = dp[1][1] * 9;
  for (int i = 3; i < 105; i++) {
    dp[i][1] = dp[i - 1][1] + 9;
    dp[i][2] = dp[i - 1][2] + dp[i - 1][1] * 9;
    dp[i][3] = dp[i - 1][3] + dp[i - 1][2] * 9;
    dp[i - 1][1] -= dp[i - 2][1];
    dp[i - 1][2] -= dp[i - 2][2];
    dp[i - 1][3] -= dp[i - 2][3];
  }
  long long ans = 0;
  long long N = S.size();
  for (int i = 1; i < N; i++) {
    ans += dp[i][K];
  }
  int notzero = 0;
  int i = 0;
  for (i = 0; i < N; i++) {
    if (K - notzero < 1) break;
    if (S[0] != '0') {
      notzero++;
      ans += dp[N - 1 - i][K - notzero] * (S[i] - '1');
    } else {
      continue;
    }
    if (i != 0 && i != N - 1) ans += dp[N - 1 - i][K - notzero + 1];
  }
  if (S[N - 1] == '0') {
    long long cnt = 0;
    for (int i = 0; i < N; i++) {
      if (S[i] != '0') cnt++;
    }
    if (cnt == K) ans++;
  } else {
    if (K - notzero == 0 && i == N) ans += (S[N - 1] - '0');
  }
  cout << ans << endl;
  return 0;
}
