#include <bits/stdc++.h>
using namespace std;
int n, k;
string s;
bool check(int mw) {
  int wait = 0;
  int l = -1;
  int ch = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] == '0') l = i;
    ++wait;
    if (wait > mw || i == n - 1) {
      if (l == -1) {
        return false;
      }
      wait = i - l;
      l = -1;
      ch++;
      if (ch > k) return false;
    }
  }
  return true;
}
int main() {
  cin >> n >> k;
  cin >> s;
  int l = 0, r = n;
  while (l + 1 < r) {
    int m = (l + r) / 2;
    if (check(m))
      r = m;
    else
      l = m;
  }
  if (check(l))
    cout << l;
  else
    cout << l + 1;
}
