#include <bits/stdc++.h>
using namespace std;
int n, k;
string s;
bool check(int mid) {
  int last = -1;
  int bars = 1;
  int cnt = 0;
  for (int i = 1; i < n - 1; i++) {
    cnt++;
    if (s[i] == '0') {
      last = i;
    }
    if (cnt > mid) {
      if (last == -1) {
        return false;
      }
      bars++;
      cnt = i - last;
      if (last != i && s[i] == '0') {
        last = i;
      } else
        last = -1;
    }
  }
  bars++;
  return bars <= k;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  cin >> s;
  int l = -1, r = n;
  while (r - l > 1) {
    int mid = l + (r - l) / 2;
    if (check(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << r << "\n";
  return 0;
}
