#include <bits/stdc++.h>
int main() {
  long long n;
  int k, a[100], i, j, m;
  scanf("%lld %d", &n, &k);
  long long t = n;
  j = 1, i = 1, m = 0;
  while (t != 0) {
    if (t % 10 == 0) {
      a[i] = j;
      i++;
      m++;
    }
    t /= 10;
    j++;
  }
  if (m < k) {
    if (m == 0)
      printf("%d\n", j - 1);
    else
      printf("%d\n", j - 2);
  } else
    printf("%d\n", a[k] - k);
}
