#include <bits/stdc++.h>
using namespace std;
long long ans, k;
string h;
void digit(string s, long long d) {
  if ((long long)s.size() > (long long)h.size() or d > k) return;
  if ((long long)s.size() == (long long)h.size()) {
    for (long long i = 0; i < (long long)h.size(); i++) {
      if (s[i] > h[i]) return;
      if (s[i] < h[i]) break;
    }
  }
  if (d == k) {
    ans++;
  }
  for (char i = '0'; i <= '9'; i++) {
    string x = s;
    x += i;
    if (x >= "1") {
      long long c = (i > '0') ? 1 : 0;
      digit(x, d + c);
    }
  }
}
signed main() {
  cin >> h >> k;
  digit("", 0);
  cout << ans << endl;
  return 0;
}
