#include <bits/stdc++.h>
int check(char *cc, int n, int k, int b) {
  int i, i_, j;
  k -= 2;
  for (i = 0, i_ = 0, j = 1; j < n; j++)
    if (cc[j] == '0') {
      if (j - i - 1 > b) {
        if (j - i_ - 1 > b || k-- == 0) return 0;
        i = i_;
      }
      i_ = j;
    }
  return 1;
}
int main() {
  static char cc[200000 + 1];
  int n, k, lower, upper;
  scanf("%d%d%s", &n, &k, cc);
  lower = -1, upper = n - 2;
  while (upper - lower > 1) {
    int b = (lower + upper) / 2;
    if (check(cc, n, k, b))
      upper = b;
    else
      lower = b;
  }
  printf("%d\n", upper);
  return 0;
}
