#include <bits/stdc++.h>
using namespace std;
int n, k, ans = 1000000;
char s[100001];
int f[100001], f2[100001];
int pointup, pointlow = 1000000;
int findr(int x) {
  if (s[x] == '0')
    return x;
  else
    findr(x + 1);
}
int findl(int x) {
  if (s[x] == '0')
    return x;
  else
    findl(x - 1);
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> s[i];
  for (int i = 1; i <= n; i++) {
    if (s[i] == '0')
      f[i] = f[i - 1] + 1;
    else
      f[i] = f[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    if (s[i] == '0') pointlow = min(pointlow, i);
    if (f[i] == k + 1) {
      pointup = i;
      break;
    }
  }
  f2[pointup] = pointlow;
  int st = pointup;
  for (int i = pointup + 1; i <= n; i++) {
    if (s[i] == '1') f2[i] = f2[i - 1] + 1;
    if (s[i] == '0') {
      while (1) {
        if (f[i] - f[pointlow - 1] == k + 1) break;
        pointlow++;
      }
    }
    while (s[pointlow] != '0') pointlow++;
    f2[i] = pointlow;
  }
  for (int i = st; i <= n; i++) {
    int pos = findr((i + f2[i]) / 2);
    ans = min(ans, max(i - pos, pos - f2[i]));
    pos = findl((i + f2[i]) / 2);
    ans = min(ans, max(i - pos, pos - f2[i]));
  }
  if (ans == 0 && k != 0)
    cout << -1;
  else
    cout << ans;
}
