#include <bits/stdc++.h>
int main(void) {
  long int N, n, K, i, j, k, c = 0, g = 0, dig[10000], digit = 0;
  scanf("%d %d", &N, &K);
  n = N;
  while (n != 0) {
    n = n / 10;
    ++digit;
  }
  for (i = 1; i <= N; i++) {
    for (j = digit; j > 0; j / 10) {
      k = 0;
      dig[k] = i / j;
      if (dig[k] != 0) {
        c = c++;
      }
      k = k++;
    }
    if (c == K) {
      g = g++;
    }
  }
  printf("%d", g);
  return 0;
}
