#include <bits/stdc++.h>
int n, k;
char arr[210000];
int possible(int max_dist) {
  int left = k - 2;
  int prev_pos = 0;
  while (left) {
    if (n - prev_pos - 2 <= max_dist) {
      return 1;
    }
    int next_pos = prev_pos + max_dist + 1;
    while (arr[next_pos] == '1') {
      next_pos--;
    }
    if (next_pos == prev_pos) {
      return 0;
    }
    prev_pos = next_pos;
    left--;
  }
  if (n - prev_pos - 2 <= max_dist) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  scanf("%d%d\n", &n, &k);
  scanf("%s", arr);
  int l = 0, r = n - 2;
  while (l < r) {
    int m = (l + r) / 2;
    if (possible(m)) {
      r = m;
    } else {
      l = m + 1;
    }
  }
  printf("%d\n", l);
}
