#include <bits/stdc++.h>
char s[201010];
int n, k;
int dp[201010];
int check(int mid) {
  dp[0] = 1;
  int last = 0;
  int i;
  for (i = 1; i < n; i++) {
    if (s[i] == '0') {
      while (s[last] == '1' || i - last - 1 > mid) {
        last++;
      }
      if (i == last) {
        return 0;
      }
      dp[i] = dp[last] + 1;
    }
  }
  if (dp[n - 1] <= k)
    return 1;
  else
    return 0;
}
int main() {
  scanf("%d%d\n", &n, &k);
  gets(s);
  int l = 0, r = n - 2, mid;
  while (r - l > 1) {
    mid = (l + r) / 2;
    if (check(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  if (check(l)) {
    r = l;
  }
  printf("%d", r);
}
