#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int cnt = 0;
  int ch = 0;
  int m = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      cnt++;
    } else {
      m = max(m, cnt);
      cnt = 0;
      ch++;
    }
  }
  if (k >= ch) {
    cout << m;
    return 0;
  }
  int l = m - 1, r = n - 2;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    int last = -1;
    int rr = 2;
    cnt = 0;
    for (int i = 1; i < n - 1; i++) {
      if (s[i] == '0') last = i;
      cnt++;
      if (cnt > mid && s[i] == '0') {
        rr++;
        cnt = 0;
      } else if (cnt > mid && s[i] == '1') {
        rr++;
        cnt = i - last;
      }
    }
    if (rr <= k) {
      r = mid;
    } else
      l = mid;
  }
  cout << r;
}
