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