function convertArray(S) {
    var current = "1";
    var count = 0;
    SDIV = []
    Array.prototype.forEach.call(S, function (s) {
        if (current == s) {
            count++;
        } else {
            SDIV.push(count);
            count = 1;
            current = (current == "0") ? "1" : "0";
        }
    });
    SDIV.push(count);
    if (SDIV.length % 2 == 1) {
        SDIV.push(0);
    }
    return SDIV;
}

// (SADD.length / 2) - 1 > K は保証
function integrateArray(SDIV, K) {
    var SITG = [];
    var first = 0;

    if (K == 0) {
        for (var i = 0; i < SDIV.length / 2; i++) {
            SITG.push(SDIV[i * 2]);
        }
        return SITG;
    }

    for (var i = 0; i < 2 * K + 1; i++) {
        first += SDIV[i];
    }
    SITG.push(first);
    // console.log((SDIV.length / 2) - K - 1);

    for (var step = 1; step < (SDIV.length / 2) - K; step++) {
        // console.log(SITG.length - 1,
        //     step*2 - 2 ,
        //     step*2 - 1 ,
        //     (step+K)*2 - 1 ,
        //     (step+K)*2);
        SITG.push(
            SITG[SITG.length - 1]
            - SDIV[step * 2 - 2]
            - SDIV[step * 2 - 1]
            + SDIV[(step + K) * 2 - 1]
            + SDIV[(step + K) * 2]
        );
    }
    return SITG;

}

function Main(input) {
    var N = parseInt(input[0])
    var K = parseInt(input[1])
    var SDIV = convertArray(input[2]); // [1の数, 0の数, 1の数...]で入る。偶数要素。
    // console.log(SDIV);
    if ((SDIV.length / 2) - 1 < K) {
        console.log(N);
        return;
    }
    var SITG = integrateArray(SDIV, K);
    var max = 0;
    SITG.forEach(element => {
        max = Math.max(max, element);
    });
    console.log(max);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));
