#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string N;
  int K;
  cin >> N >> K;
  vector<vector<vector<long long>>> dp(
      N.size() + 1, vector<vector<long long>>(2, vector<long long>(K + 1)));
  dp[0][0][0] = 1;
  for (int i = 0; i < (N.size()); i++) {
    dp[i + 1][0][0] = dp[i][0][0] * (N[i] == '0');
    dp[i + 1][1][0] = dp[i][0][0] + dp[i][1][0];
    for (int j = 0; j < (K); j++) {
      dp[i + 1][0][j + 1] = (N[i] == '0') ? dp[i][0][j + 1] : dp[i][0][j];
      dp[i + 1][1][j + 1] = dp[i][0][j] * (N[i] - '1') +
                            dp[i][0][j + 1] * (N[i] > '0') + dp[i][1][j] * 9 +
                            dp[i][1][j + 1];
    }
  }
  cout << dp[N.size()][0][K] + dp[N.size()][1][K] << endl;
  return 0;
}
