#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)(1e9 + 7);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string N;
int K;
long long dp[100][4][2];
long long solve(int n, int nokori, int pitari) {
  if (nokori < 0) return 0LL;
  if (n == N.size()) {
    if (nokori == 0)
      return 1LL;
    else
      return 0LL;
  }
  if (dp[n][nokori][pitari] != -1) return dp[n][nokori][pitari];
  long long ret = solve(n + 1, nokori, 0);
  for (int i = 1; i < 10; i++) {
    if (pitari == 1 && N[n] - '0' < i) continue;
    if (pitari == 1 && N[n] - '0' == i)
      ret += solve(n + 1, nokori - 1, 1);
    else
      ret += solve(n + 1, nokori - 1, 0);
  }
  return dp[n][nokori][pitari] = ret;
}
signed main() {
  cin >> N >> K;
  memset(dp, -1, sizeof(dp));
  cout << solve(0, K, 1) << endl;
}
