#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MOD2 = 998244353;
const long long N = 2e5 + 5;
const long double pi = 3.14159265359;
long long r, l, n, k, p[N], mid;
string s;
bool b(long long len) {
  long long ti = 1, id = 0;
  while (id < (long long)s.size() - 1) {
    if (id + len + 1 < (long long)s.size()) {
      if (p[id + len + 1] == id) return 0;
      ti++;
      id = p[id + len + 1];
    } else {
      id = (long long)s.size() - 1;
      ti++;
    }
  }
  return ti <= k;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k >> s;
  for (long long i = 0; i < (long long)s.size(); i++) {
    p[i] = (s[i] == '1' ? p[i - 1] : i);
  }
  r = n - 2;
  l = -1;
  while (r - l > 1) {
    mid = (r + l) / 2;
    if (b(mid))
      r = mid;
    else
      l = mid;
  }
  cout << r << "\n";
  return 0;
}
