#include <bits/stdc++.h>
using namespace std;
string arr;
long long p;
long long dp[101][4][2] = {};
void init() {
  for (int i = 0; i < 101; i++)
    for (int j = 0; j < 4; j++)
      for (int k = 0; k < 2; k++) dp[i][j][k] = -1;
}
long long calc(int i, int j, bool k) {
  if (i == arr.size()) {
    if (j == 0)
      return 1;
    else
      return 0;
  }
  if (j == 0) return 1;
  if (dp[i][j][k] != -1) return dp[i][j][k];
  long long ans = 0;
  if (k == true) {
    ans = calc(i + 1, j, true) + 9 * calc(i + 1, j - 1, true);
  } else {
    ans = calc(i + 1, j, true) + calc(i + 1, j - 1, false) +
          (arr[i] - 1 - '0') * calc(i + 1, j - 1, true);
  }
  dp[i][j][k] = ans;
  return ans;
}
void solve() {
  cin >> arr;
  cin >> p;
  long long ans = 0;
  init();
  ans += calc(0, p, false);
  cout << ans << endl;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
