#include <bits/stdc++.h>
using namespace std;
int ans = 0, k;
string s;
void solve(int pos, string x = "") {
  if (pos > s.size() || x > s) return;
  int cnt = 0;
  for (int i = 0; i < x.size(); ++i) {
    cnt += (x[i] != '0');
  }
  if (cnt == k) {
    ++ans;
  }
  char c = (pos == 0 ? '1' : '0');
  for (; c <= '9'; ++c) {
    x.push_back(c);
    solve(pos + 1, x);
    x.pop_back();
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s >> k;
  solve(0);
  cout << ans << endl;
  return 0;
}
