#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, l, r, m;
  string s;
  cin >> n >> k;
  getline(cin, s);
  getline(cin, s);
  l = 0;
  r = n - 1;
  while (r - l > 0) {
    m = (r + l) / 2;
    int x = 1, y = 1, k1 = 1;
    int i = 2;
    while (i <= n) {
      if (s[i - 1] == '0') x = i;
      if (i - y > m || i == n) {
        if (x == y) k1 = k + 2;
        y = x;
        k1++;
      }
      i++;
    }
    if (k1 > k)
      l = m + 1;
    else
      r = m;
  }
  cout << max(0, l);
  return 0;
}
