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