"use strict";

function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0], 10);
  var K = parseInt(input[0].split(" ")[1], 10);
  var S = [...input[1]].map(function (v) {
    return parseInt(v, 10);
  });
  var array = [];
  var now = 1;
  var localLen = 0;

  for (var i = 0; i < N; i++) {
    if (S[i] === now) {
      localLen++;
    } else {
      array.push(localLen);
      now = S[i];
      localLen = 1;
    }
  }

  array.push(localLen);

  if (array.length % 2 == 0) {
    array.push(0);
  } //console.log(array);


  var sum = [];
  var final = array.reduce(function (a, c) {
    sum.push(a);
    return a + c;
  });
  sum.push(final); //console.log(sum);

  var max = 0;

  for (var _i = 0; _i < sum.length - 2 * K; _i += 2) {
    var right = _i + 2 * K;
    var left = _i - 1;
    //console.log(left, right);
    var lSum = sum[right];
    lSum -= left >= 0 ? sum[left] : 0;

    if (lSum > max) {
      max = lSum;
    }
  }

  console.log(max);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));