#include <bits/stdc++.h>
using namespace std;
const long long N = 110;
string n;
long long k, dp[N][N][2];
long long solve(long long digit, long long cnt, long long flag) {
  if (dp[digit][cnt][flag] != -1) return dp[digit][cnt][flag];
  if (cnt > k) return dp[digit][cnt][flag] = 0;
  if (digit == n.size()) {
    if (cnt == k) {
      return dp[digit][cnt][flag] = 1;
    }
    return dp[digit][cnt][flag] = 0;
  }
  long long res = 0;
  long long limit;
  if (!flag)
    limit = n[digit] - '0';
  else
    limit = 9;
  for (long long d = 0; d <= limit; d++) {
    long long nxtf = flag;
    long long nxtcnt = cnt;
    if (flag == 0 && d < limit) nxtf = 1;
    if (flag == 0 && !d) nxtf = 1;
    if (d == 0) nxtf = 1;
    if (d != 0) nxtcnt++;
    if (nxtcnt <= k) res += solve(digit + 1, nxtcnt, nxtf);
  }
  return dp[digit][cnt][flag] = res;
}
int main() {
  cin >> n;
  scanf("%lld", &k);
  memset(dp, -1, sizeof dp);
  printf("%lld\n", solve(0, 0, 0));
  return 0;
}
