#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);
    int s_length = s.length();
    int length = 0;
    for (int j = 0; j < s_length; j++) {
      if (s[j] != '0') length++;
      if (length > k) {
        length = 0;
        break;
      }
    }
    if (length == k) num++;
  }
  cout << num << endl;
  return 0;
}
