#include <bits/stdc++.h>
using namespace std;
string n;
long long k;
long long dp[105][105][2];
long long rec(long long i, long long rem, long long fl) {
  if (i == n.size()) return (rem == 0);
  long long &res = dp[i][rem][fl];
  if (res != -1) return res;
  res = 0;
  res = rec(i + 1, rem, (n[i] > '0' or fl));
  if (rem) {
    long long mx = 9;
    if (!fl) mx = n[i] - '0';
    long long c = rec(i + 1, rem - 1, 1);
    for (long long i = 1; i < mx; i++) res += c;
    res += rec(i + 1, rem - 1, fl);
  }
  return res;
}
void solve() {
  cin >> n >> k;
  memset(dp, -1, sizeof dp);
  cout << rec(0, k, 0);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}
