#include <bits/stdc++.h>
using namespace std;
vector<vector<vector<long long> > > dp(
    101, vector<vector<long long> >(4, vector<long long>(3, 0)));
void Main() {
  string S;
  long long K;
  cin >> S;
  scanf("%lld", &K);
  ;
  long long N = S.size();
  if (K > N) {
    cout << 0 << endl;
  } else {
    if (N == 1) {
      cout << S[0] << endl;
    } else {
      long long now_num_nzero = 1;
      dp[0][1][2] = 1;
      dp[0][1][1] = S[0] - '1';
      dp[0][0][0] = 1;
      for (long long i = 1; i < N; ++i) {
        bool is_prev_zero = S[i - 1] == '0';
        now_num_nzero += (S[i] != '0');
        long long max_k = min(now_num_nzero, K);
        if (now_num_nzero > K) {
          dp[i][K][2] = 0;
        } else {
          dp[i][now_num_nzero][2] = 1;
        }
        for (long long k = 1; k <= K; ++k) {
          dp[i][k][1] = (dp[i - 1][k - 1][0] + dp[i - 1][k - 1][1]) * 9;
          dp[i][k][0] = dp[i - 1][k][1];
          if (i > 1) {
            dp[i][k][0] += dp[i - 1][k][0];
          }
          if (!is_prev_zero) {
            long long mid_num;
            if (now_num_nzero > K) {
              mid_num = S[i] - '0';
            } else {
              mid_num = S[i] - '1';
              mid_num = max(0LL, mid_num);
            }
            dp[i][k][1] += dp[i - 1][k - 1][2] * mid_num;
            if (S[i] != '0' || now_num_nzero > K) {
              dp[i][k][0] += dp[i - 1][k][2];
            }
          }
        }
        dp[i][0][0] = 1;
      }
      long long ans = 0;
      for (long long i = 0; i < 3; ++i) {
        ans += dp[N - 1][K][i];
      }
      cout << ans << endl;
    }
  }
}
int main() { Main(); }
