#include <bits/stdc++.h>
int main() {
  int k;
  char a[20];
  scanf("%s %d", a, &k);
  int l = strlen(a);
  int ans = 0;
  int mark = 0;
  if ((l - 1) < k)
    printf("%d\n", l - 1);
  else {
    for (int i = l - 1; i >= 0; i--) {
      if (a[i] == '0')
        ans++;
      else
        mark++;
      if (ans == k) break;
    }
    if (ans == k)
      printf("%d\n", mark);
    else
      printf("%d\n", l - 1);
  }
}
