"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 = [0];

  for (var _i = 0; _i < array.length; _i++) {
    sum.push(sum[_i] + array[_i]);
  } //console.log(sum);


  var max = 0;

  for (var _i2 = 0; _i2 < array.length; _i2 += 2) {
    var left = _i2;
    var right = Math.min(_i2 + 2 * K + 1, array.length); //console.log(left, right);

    lSum = sum[right] - sum[left]; //console.log(sum[right], sum[left]);

    max = Math.max(max, lSum);
  }

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