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