#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int c = 0;
  for (long long int i = 1; i <= n; i++) {
    long long int temp = i;
    long long int num = log10(i) + 1;
    long long int arr[num];
    for (long long int j = 0; j < num; j++) {
      arr[j] = temp % 10;
      temp = temp / 10;
    }
    long long int count = 0;
    for (long long int j = 0; j < num; j++) {
      if (arr[j] != 0) count++;
    }
    if (count == k) c++;
  }
  cout << c;
  return 0;
}
