#include <bits/stdc++.h>
int a[15];
int main() {
  long long m, t;
  int n, i, j, count = 0, sum = 0, len;
  scanf("%lld%d", &m, &n);
  t = m;
  for (i = 1; t != 0; i++) {
    a[i] = t % 10;
    t /= 10;
  }
  len = i - 1;
  for (j = 1; j <= i - 1; j++) {
    if (a[j] == 0) count++;
    if (count == n) {
      t = j;
      break;
    }
  }
  for (i = 1; i <= t; i++)
    if (a[i]) sum++;
  if (m == 0)
    printf("0\n");
  else {
    if (count < n)
      printf("%d\n", len - 1);
    else
      printf("%d\n", sum);
  }
  return 0;
}
