#include <bits/stdc++.h>
using namespace std;
vector<long long> v(102);
int dp[101][3][2];
int k;
int find(int pos, int cnt, int f) {
  if (cnt > k) return 0;
  if (pos == v.size()) {
    if (cnt == k) return 1;
    return 0;
  }
  if (dp[pos][cnt][f] != -1) {
    return dp[pos][cnt][f];
  }
  int res = 0;
  int LMT;
  if (f == 0) {
    LMT = v[pos];
  } else
    LMT = 9;
  for (auto dgt = 0; dgt <= LMT; dgt++) {
    int nf = f;
    int ncnt = cnt;
    if (f == 0 && dgt < LMT) nf = 1;
    if (dgt != 0) ncnt++;
    if (ncnt <= k) res += find(pos + 1, ncnt, nf);
  }
  return dp[pos][cnt][f] = res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  cin >> k;
  v.resize(s.length());
  memset(dp, -1, sizeof(dp));
  for (auto i = 0; i < s.length(); i++) {
    v[i] = (int)(s[i] - 48);
  }
  cout << find(0, 0, 0) << "\n";
  return 0;
}
