#include <bits/stdc++.h>
int d[105];
char s[15];
int main() {
  int N, K;
  scanf("%s%d", s, &K);
  int j = 0;
  for (int i = strlen(s) - 1; i >= 0; i--) {
    d[j++] = s[i] - '0';
  }
  int nub = 0;
  int cut = 0;
  for (int i = 0; i < j; i++) {
    if (d[i] == 0)
      nub++;
    else
      cut++;
    if (nub == K) break;
  }
  if (nub == K)
    printf("%d\n", cut);
  else
    printf("%d\n", j - 1);
}
