#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int input;
  int k;
  scanf("%lld", &input);
  scanf("%d", &k);
  int i, perc, count, ans = 0;
  for (i = 1; i <= input; i++) {
    int ori = i;
    count = 0;
    while (count <= k) {
      perc = ori % 10;
      if (perc != 0) {
        count = count + 1;
      }
      if (ori <= 0) {
        break;
      }
      ori = ori / 10;
    }
    if (count == k && ori <= 0) {
      ans = ans + 1;
    }
  }
  printf("%d", ans);
}
