#include <bits/stdc++.h>
using namespace std;
int64_t check(int64_t n) {
  string m = to_string(n);
  int64_t count = 0LL;
  for (int i = 0; i < m.size(); i++) {
    if (m.at(i) == '0') {
      count++;
    }
  }
  return m.size() - count;
}
int main() {
  int n, k;
  cin >> n;
  cin >> k;
  int64_t count = 0LL;
  for (int i = 0; i <= n; i++) {
    if (check(i) == k) {
      count++;
    }
  }
  cout << count << endl;
}
