#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int K;
  int cnt = 0;
  cin >> N >> K;
  int b[N];
  string a;
  for (int i = 0; i <= N; i++) {
    b[i] = 0;
  }
  for (int i = 1; i <= N; i++) {
    a = to_string(i);
    for (int j = 0; j < a.size(); j++) {
      if (a[j] != '0') {
        b[i] = b[i] + 1;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    if (b[i] == K) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
