#include <bits/stdc++.h>
using namespace std;
int dp[105][4][2];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k;
  string s;
  cin >> s >> k;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 3; j++) {
      int dig = (s[n - 1 - i] - '0');
      if (j == 0) {
        dp[i][j][0] = dp[i][j][1] = 1;
        continue;
      }
      if (i == 0) {
        if (j == 1) {
          dp[i][j][0] = 9;
          dp[i][j][1] = dig;
        } else {
          dp[i][j][0] = dp[i][j][1] = 0;
        }
        continue;
      }
      dp[i][j][0] = dp[i][j][1] = dp[i - 1][j][0];
      dp[i][j][1] += ((dig - 1 <= 0) ? 0 : dig - 1) * dp[i - 1][j - 1][0] +
                     dp[i - 1][j - 1][1];
      dp[i][j][0] += 9 * dp[i - 1][j - 1][0];
    }
  }
  cout << dp[n - 1][k][1] << '\n';
  return 0;
}
