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