#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  string s;
  cin >> n >> k >> s;
  int l = -1, r = n;
  while (l + 1 < r) {
    int m = (l + r) >> 1, c = 1, b = 0, d = 0;
    for (int i = 1; i < n; i++) {
      if (s[i] == '0') b = i;
      if (i - b > m) c = 1000000007;
      if (i == n - 1 || i - d == m + 1) {
        c++;
        d = b;
      }
    }
    if (c <= k)
      r = m;
    else
      l = m;
  }
  cout << r << '\n';
}
