#include <bits/stdc++.h>
using namespace std;
constexpr long long int linf = numeric_limits<long long int>::max() - 5;
constexpr int inf = numeric_limits<int>::max() - 5;
constexpr long long int mod = 1000000007;
int main() {
  string s;
  cin >> s;
  long long int c;
  cin >> c;
  long long int digit_num = s.size();
  long long int zero_num = digit_num - c;
  vector<vector<vector<long long int>>> dp(
      digit_num + 1,
      vector<vector<long long int>>(2, vector<long long int>(120, 0)));
  long long int x0 = (long long int)(s[0] - '0');
  dp[0][0][0] = x0 - 1;
  dp[0][0][1] = 1;
  dp[0][1][0] = 1;
  for (long long int i = (1); (i) < (digit_num); (i)++) {
    long long int xi = (long long int)(s[i] - '0');
    if (xi == 0) {
      dp[i][0][0] += dp[i - 1][0][0] * 9 + dp[i - 1][0][0 + 1] * 0 +
                     dp[i - 1][1][0] * (0) + dp[i - 1][1][0 + 1] * 0;
      for (long long int j = 0; (j) < (110); j++) {
        dp[i][0][j + 1] += dp[i - 1][0][j] * 1 + dp[i - 1][0][j + 1] * 9 +
                           dp[i - 1][1][j] * (0) + dp[i - 1][1][j + 1] * 0;
        dp[i][1][j + 1] += dp[i - 1][0][j] * 0 + dp[i - 1][0][j + 1] * 0 +
                           dp[i - 1][1][j] * (1) + dp[i - 1][1][j + 1] * 0;
      }
    } else {
      dp[i][0][0] += dp[i - 1][0][0] * 9 + dp[i - 1][0][0 + 1] * 0 +
                     dp[i - 1][1][0] * (xi - 1) + dp[i - 1][1][0 + 1] * 0;
      for (long long int j = 0; (j) < (110); j++) {
        dp[i][0][j + 1] += dp[i - 1][0][j] * 1 + dp[i - 1][0][j + 1] * 9 +
                           dp[i - 1][1][j] * (1) +
                           dp[i - 1][1][j + 1] * (xi - 1);
        dp[i][1][j] += dp[i - 1][0][j] * 0 + dp[i - 1][0][j + 1] * 0 +
                       dp[i - 1][1][j] * (1) + dp[i - 1][1][j + 1] * 0;
      }
    }
  }
  cout << dp[digit_num - 1][1][zero_num] + dp[digit_num - 1][0][zero_num]
       << endl;
  return 0;
}
