#include <bits/stdc++.h>
using namespace std;
bool possible(vector<int> pos, int brk, int k) {
  k -= 2;
  int prev_bar = 0;
  bool flag = true;
  for (int i = 1; i < pos.size() - 1; i++) {
    if (k == 0) break;
    if (pos[i] - pos[prev_bar] - 1 > brk) {
      if (prev_bar + 1 == i) {
        flag = false;
        break;
      }
      i--;
      prev_bar = i;
      k--;
    }
  }
  if (!flag) return false;
  if (pos[pos.size() - 1] - pos[prev_bar] - 1 > brk) {
    if (k > 0 && pos[pos.size() - 2] != prev_bar) {
      k--;
      prev_bar = pos.size() - 2;
      if (pos[pos.size() - 1] - pos[prev_bar] - 1 > brk)
        return false;
      else
        return true;
    }
    return false;
  } else
    return true;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> pos;
  string v;
  cin >> v;
  for (int i = 0; i < n; i++) {
    if (v[i] - 48 == 0) pos.push_back(i + 1);
  }
  int left = 0, right = n - 1;
  int mid;
  int ans = -1;
  while (left <= right) {
    mid = left + (right - left) / 2;
    bool check = possible(pos, mid, k);
    if (check) {
      ans = mid;
      right = mid - 1;
    } else {
      left = mid + 1;
    }
  }
  cout << ans << "\n";
}
