#include <bits/stdc++.h>
const int MAXN = 200005;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long L_INF = 4e18;
const long double EPS = 1e-10;
bool check(int n, int k, int t, const char* s) {
  t++;
  k--;
  int last = 0;
  while (last < n - 1) {
    int j = 1, new_last = -1;
    while (j <= t && last + j < n) {
      if (s[last + j] == '0') new_last = last + j;
      j++;
    }
    k--;
    if (new_last == -1) return false;
    last = new_last;
  }
  return k >= 0;
}
int main() {
  int n, k;
  char s[MAXN];
  memset(s, 0, sizeof s);
  scanf("%d %d ", &n, &k);
  for (int i = 0; i < n; i++) scanf("%c ", &s[i]);
  int l = 0, r = n;
  while (l != r) {
    int m = (l + r) >> 1;
    if (check(n, k, m, s)) {
      r = m;
    } else {
      l = m + 1;
    }
  }
  printf("%d\n", l);
  return 0;
}
