#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int k;
  int i;
  int num;
  int count = 0;
  int sum = 0;
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    num = i;
    count = 0;
    while (count != k && num != 0) {
      if (num % 10 != 0) count++;
      num /= 10;
    }
    if (num == 0 && count == k) sum++;
  }
  cout << sum;
  return 0;
}
