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