#include <bits/stdc++.h>
using namespace std;
string s;
int k, len;
int dp[105][5][2];
int dfs(int i, int r, int limit) {
  if (dp[i][r][limit] != -1) return dp[i][r][limit];
  dp[i][r][limit] = 0;
  if (r == 0 && i <= len)
    dp[i][r][limit] = 1;
  else if (len - i >= r) {
    if (limit) {
      if (s[i] == '0')
        dp[i][r][1] += dfs(i + 1, r, 1);
      else {
        dp[i][r][1] += (s[i] - '0' - 1) * dfs(i + 1, r - 1, 0);
        dp[i][r][1] += dfs(i + 1, r - 1, 1);
      }
    } else {
      dp[i][r][0] += dfs(i + 1, r, 0);
      dp[i][r][0] += 9 * dfs(i + 1, r - 1, 0);
    }
  }
  return dp[i][r][limit];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s >> k;
  memset(dp, -1, sizeof(dp));
  len = s.length();
  cout << (s[0] - '0' - 1) * dfs(1, k - 1, 0) + dfs(1, k, 0) + dfs(1, k - 1, 1)
       << "\n";
  return 0;
}
