#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int res = 0;
  for (int i = 0; i < N; i++) {
    string S = to_string(i + 1);
    int counter = 0;
    for (char j : S) {
      if (j != '0') {
        ++counter;
      }
    }
    if (counter == K) {
      ++res;
    }
  }
  cout << res << endl;
}
