#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  long long N, K;
  cin >> N >> K;
  int k_count = 0;
  for (int i = 1; i <= N; i++) {
    int count = 0;
    int temp = i;
    while (1) {
      if ((temp % 10) == 0) {
        temp /= 10;
      } else {
        temp -= (temp % 10);
        temp /= 10;
        count += 1;
      }
      if (temp == 0) {
        break;
      }
    }
    if (count == K) {
      k_count += 1;
    }
  }
  cout << k_count << "\n";
  return 0;
}
