#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long m = 1000000007) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long res = power(a, b / 2, m);
  res = (res * res) % m;
  if (b & 1) res = (res * a) % m;
  return res;
}
long long modinv(long long a, long long m = 1000000007) {
  return power(a, m - 2, m);
}
long long add(long long a, long long b, long long m = 1000000007) {
  long long c = (a % m + b % m);
  if (c >= m) c -= m;
  return c;
}
long long sub(long long a, long long b, long long m = 1000000007) {
  long long c = (a % m - b % m);
  if (c < 0) c += m;
  return c;
}
long long mul(long long a, long long b, long long m = 1000000007) {
  return (a * b) % m;
}
string s;
long long check(long long val) {
  long long n = s.length(), a, b, x;
  vector<long long> v = {0};
  for (long long i = 1; i < n; i++) {
    if (s[i] == '1') continue;
    x = v.size();
    a = i - v[x - 1] - 1;
    if (x > 1) b = i - v[x - 2] - 1;
    if (a > val) return 1e9;
    if (x > 1 && b <= val)
      v[x - 1] = i;
    else
      v.push_back(i);
  }
  return v.size();
}
void solve() {
  long long n, k;
  cin >> n >> k >> s;
  long long low = 0, high = n - 2, mid, ans = n - 2;
  while (low <= high) {
    mid = (low + high) / 2;
    if (check(mid) <= k) {
      ans = mid;
      high = mid - 1;
    } else
      low = mid + 1;
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  for (long long i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
