#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  int num = 0;
  for (int i = 1; i <= n; i++) {
    s = std::to_string(i);
    s.erase(remove(s.begin(), s.end(), '0'), s.end());
    if (s.length() == k) num++;
  }
  cout << num << endl;
  return 0;
}
