#include <bits/stdc++.h>
int main() {
  long long int n;
  int k;
  scanf("%lld %d", &n, &k);
  if (n == 0) {
    printf("0");
    return 0;
  }
  int count = 0;
  int a = 0;
  int temp = 0;
  long long int d = n;
  while (d != 0 && a != k) {
    if (d % 10 == 0)
      a++;
    else
      count++;
    d = d / 10;
    temp++;
  }
  if (d != 0)
    printf("%d", count);
  else {
    int count1 = 0;
    while (n != 0) {
      count1++;
      n = n / 10;
    }
    printf("%d", count1 - 1);
  }
}
