#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  long long k;
  cin >> k;
  long long n = ((long long)(s).length());
  vector<vector<vector<long long>>> dp(
      n + 1, vector<vector<long long>>(k + 1, vector<long long>(2, 0)));
  dp[0][0][0] = 1;
  for (long long i = 0, i_len = (n); i < i_len; i++) {
    long long v = s[i] - '0';
    for (long long j = 0, j_len = (k + 1); j < j_len; j++) {
      if (v == 0) dp[i + 1][j][0] += dp[i][j][0];
      if ((v > 0) && (j > 0)) dp[i + 1][j][0] += dp[i][j - 1][0];
      if (v > 0) dp[i + 1][j][1] += dp[i][j][0];
      dp[i + 1][j][1] += dp[i][j][1];
      if (j > 0)
        dp[i + 1][j][1] += dp[i][j - 1][0] * (v - 1) + dp[i][j - 1][1] * 9;
    }
  }
  cout << (dp[n][k][0] + dp[n][k][1]) << endl;
  return 0;
}
