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