#include <bits/stdc++.h>
using namespace std;
int n, k;
string s;
int solve(int i, int cnt, int upper, bool limit) {
  if (i == n) {
    if (cnt == 0) return 1;
    return 0;
  }
  if (cnt == 0) return 1;
  if (limit) {
    return solve(i + 1, cnt - 1, s[i + 1] - '0', true) +
           solve(i + 1, cnt - 1, 0, false) * (upper - 1) +
           solve(i + 1, cnt, s[i + 1] - '0', upper == 0);
  } else {
    return solve(i + 1, cnt - 1, 0, false) * 9 + solve(i + 1, cnt, 0, false);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> s >> k;
  n = s.length();
  int res = solve(0, k, s[0] - '0', true);
  cout << res << endl;
  return 0;
}
