#include <bits/stdc++.h>
using namespace std;
int main() {
  string n;
  int k;
  int count = 0;
  int ans = 0;
  cin >> n >> k;
  vector<string> nums(stoi(n));
  for (int i = 0; i < nums.size(); i++) {
    nums.at(i) = to_string(i + 1);
  }
  for (int i = 0; i < nums.size(); i++) {
    count = 0;
    for (char num : nums.at(i)) {
      if (num != '0') {
        count++;
      }
    }
    if (count == k) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
