#include <bits/stdc++.h>
using namespace std;
string s;
int dp[102][5][2], k;
long long dpsolve(int pos, int cnt, int f) {
  cout << pos << " " << cnt << " " << f << "\n";
  if (cnt > k) return 0;
  if (pos == s.size()) {
    if (cnt == k) return 1;
    return 0;
  }
  if (dp[pos][cnt][f] != -1) return dp[pos][cnt][f];
  long long ans = 0;
  int lmt;
  if (f == 0) {
    lmt = s[pos] - '0';
  } else {
    lmt = 9;
  }
  for (int dgt = 0; dgt <= lmt; dgt++) {
    int nf = f;
    int ncnt = cnt;
    if (dgt != 0) ncnt++;
    if (f == 0 && dgt < lmt) nf = 1;
    if (ncnt <= k) ans += dpsolve(pos + 1, ncnt, nf);
  }
  return dp[pos][cnt][f] = ans;
}
int main() {
  cin >> s >> k;
  memset(dp, -1, sizeof(dp));
  long long res = dpsolve(0, 0, 0);
  cout << res << "\n";
  return 0;
}
