#include <bits/stdc++.h>
using namespace std;
long long dp[200][200][2];
vector<long long> num;
long long n, k;
long long solve(long long pos, long long cnt, long long flag) {
  if (cnt > k) return 0;
  if (pos == num.size()) {
    if (cnt == k)
      return 1;
    else
      return 0;
  }
  if (dp[pos][cnt][flag] != -1) return dp[pos][cnt][flag];
  long long res = 0;
  long long limit;
  if (flag == 0)
    limit = num[pos];
  else
    limit = 9;
  for (long long digit = 0; digit <= limit; digit++) {
    long long nf = flag;
    long long ncnt = cnt;
    if (digit != 0) ncnt++;
    if (flag == 0 && digit < limit) nf = 1;
    if (ncnt <= k) res += solve(pos + 1, ncnt, nf);
  }
  return dp[pos][cnt][flag] = res;
}
long long solve1(long long n) {
  num.clear();
  while (n) {
    num.push_back(n % 10);
    n /= 10;
  }
  memset(dp, -1, sizeof(dp));
  reverse(num.begin(), num.end());
  long long result = solve(0, 0, 0);
  return result;
}
int32_t main() {
  cin >> n >> k;
  cout << solve1(n) << "\n";
  return 0;
}
