#include <bits/stdc++.h>
using namespace std;
char s[110];
int main() {
  scanf("%s", s);
  int k;
  scanf("%d", &k);
  int len = strlen(s);
  int pos = -1, cnt = 0;
  for (int i = len - 1; i >= 0; i--) {
    if (s[i] == '0') cnt++;
    if (cnt == k) {
      pos = i;
      break;
    }
  }
  if (pos == -1)
    printf("%d\n", len - 1);
  else
    printf("%d\n", len - pos - cnt);
  return 0;
}
