#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  long long rt = 0, st = 1;
  while (st <= n) {
    string str = to_string(st);
    long long count = 0;
    for (long long i = 0; i < str.size(); i++) {
      if (str[i] != '0') count++;
    }
    if (count == k) rt++;
    st++;
  }
  cout << rt << endl;
  return 0;
}
