"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

!function () {
  function splitNum(line) {
    return (Array.isArray(line) ? line : line.split(/\s+/)).map(function (n) {
      return parseInt(n);
    });
  }

  !function (input) {
    var lines = input.split("\n");

    var _splitNum = splitNum(lines[0]),
        _splitNum2 = _slicedToArray(_splitNum, 2),
        N = _splitNum2[0],
        K = _splitNum2[1];

    var S = lines[1].slice(0, N);

    var _ref = function () {
      var ones = [];
      var zeroes = [];
      var cur = 1;
      var num = 0;
      var _iteratorNormalCompletion = true;
      var _didIteratorError = false;
      var _iteratorError = undefined;

      try {
        for (var _iterator = S[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
          var c = _step.value;
          if (c === String(cur)) num++;else {
            (1 === cur ? ones : zeroes).push(num);
            num = 1;
            cur ^= 1;
          }
        }
      } catch (err) {
        _didIteratorError = true;
        _iteratorError = err;
      } finally {
        try {
          if (!_iteratorNormalCompletion && _iterator.return != null) {
            _iterator.return();
          }
        } finally {
          if (_didIteratorError) {
            throw _iteratorError;
          }
        }
      }

      (1 === cur ? ones : zeroes).push(num);
      if (1 == (cur ^= 1)) ones.push(0);
      return {
        ones: ones,
        zeroes: zeroes
      };
    }(),
        ones = _ref.ones,
        zeroes = _ref.zeroes;

    if (zeroes.length <= K) {
      console.log(N);
      return;
    }

    var acc = ones.slice(0, K + 1).concat(zeroes.slice(0, K)).reduce(function (a, b) {
      return a + b;
    }, 0);
    var max = acc;

    for (var i = K; i < zeroes.length; i++) {
      if (max < (acc = acc + ones[i + 1] - ones[i - K] + zeroes[i] - zeroes[i - K])) max = acc;
    }

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