import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long K, string S) {
    auto runlength = S.group.array;
    if (runlength[0][0] == dchar('0'))
        runlength = tuple(dchar('1'), 0u) ~ runlength;
    if (runlength[$ - 1][0] == '0')
        runlength = runlength ~ tuple(dchar('1'), 0u);
    
    long store;
    long ans;
    twoPointers(
        runlength.length,
        (i, j) {return j - i <= (K == 1 ? 1 : (2 * K));},
        (i) {store += runlength[i][1];},
        (i) {store -= runlength[i][1];},
        () {ans = ans.max(store);}
    );

    return ans;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long K;
    K = input.front.to!long;
    input.popFront;

    string S;
    S = input.front.to!string;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(N, K, S);
    else
        solve(N, K, S).writeln;
}


void twoPointers(
    size_t arrayLength,
    bool delegate(size_t, size_t) isValidRange,
    void delegate(size_t) pushFront,
    void delegate(size_t) popBack,
    void delegate() processRange,
) {
    pushFront(0);
    size_t first = 0;
    size_t last = 0;

    bool empty() { return first > last; }
    bool existsNext() { return last + 1 < arrayLength; }

    do {
        while (empty() || (existsNext() && isValidRange(first, last + 1))) {
            last++;
            pushFront(last);
        }
        processRange();
        popBack(first);
        first++;
    } while (first < arrayLength && existsNext());
}
