#include <bits/stdc++.h>
char s[200000];
int f(int x, int k) {
  k--;
  int n = strlen(s);
  int last = 0;
  int lastzero = -1;
  int mx = 0;
  if (k - 1 <= 0) return n - 2 <= x;
  for (int i = 1; i < n; i++) {
    if (i - last - 1 > x) {
      if (k > 0)
        k--;
      else
        return 0;
      if (lastzero == -1) return 0;
      if (lastzero - last - 1 > mx) mx = lastzero - last - 1;
      last = lastzero;
      lastzero = -1;
    }
    if (s[i] == '0') lastzero = i;
  }
  if (k <= 0) return 0;
  if (n - last - 2 > mx) mx = n - last - 2;
  return mx <= x;
}
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int l = 0, r = n + 1;
  scanf("%s", &s);
  s[0] = '1';
  while (l < r) {
    int mid = l + r >> 1;
    if (!f(mid, k))
      l = mid + 1;
    else
      r = mid;
  }
  printf("%d", r);
}
