#include <bits/stdc++.h>
using namespace std;
string b;
long long k;
vector<long long> num;
long long dp[10000000][12][2];
long long call(long long pos, long long cnt, long long f) {
  if (cnt > k) return 0;
  if (num.size() == pos) {
    if (cnt == k) return 1;
    return 0;
  }
  long long limit, res = 0;
  if (dp[pos][cnt][f] != -1) return dp[pos][cnt][f];
  if (f == 0)
    limit = num[pos];
  else
    limit = 9;
  for (long long i = 0; i <= limit; i++) {
    long long nf = f;
    long long ncnt = cnt;
    if (i < limit) nf = 1;
    if (i != 0) ncnt++;
    if (cnt <= k) res += call(pos + 1, ncnt, nf);
  }
  return dp[pos][cnt][f] = res;
}
long long solve(string b) {
  num.clear();
  for (long long i = 0; i < b.length(); i++) {
    num.push_back(b[i] - '0');
  }
  memset(dp, -1, sizeof(dp));
  long long res = call(0, 0, 0);
  return res;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> b >> k;
  long long res = solve(b);
  cout << res << '\n';
  return 0;
}
