#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  std::cin >> s;
  long long n = s.size();
  long long k;
  std::cin >> k;
  vector<vector<vector<long long>>> dp(
      n + 1, vector<vector<long long>>(k + 1, vector<long long>(2, 0)));
  dp[0][0][1] = 1;
  for (int i = 0; i < n; i++) {
    long long x = s[i] - '0';
    for (int j = 0; j <= k; j++) {
      if (x == 0) {
        dp[i + 1][j][1] = dp[i][j - 1][1];
      } else {
        if (j - 1 >= 0) dp[i + 1][j][1] = dp[i][j - 1][1];
        if (j - 1 >= 0) dp[i + 1][j][0] += dp[i][j - 1][1] * (x - 1);
        dp[i + 1][j][0] += dp[i][j][1];
      }
      if (j - 1 >= 0) dp[i + 1][j][0] += dp[i][j - 1][0] * 9;
      dp[i + 1][j][0] += dp[i][j][0];
    }
  }
  std::cout << dp[n][k][0] + dp[n][k][1] << std::endl;
}
