import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Node = Tuple!(long, "p", long, "dist");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, k;
    scan(n, k);
    auto s = sread();
    if(s[$ - 1] == '1')
    {
        s ~= '0';
    }
    else
    {
        s ~= "10";
    }
    auto stand = new long[](1);
    auto hand = new long[](1);
    long s_count, h_count;
    foreach (i; iota(s.length))
    {
        if(s[i] == '1')
            h_count++;
        else
            s_count++;

        if(i > 0)
        {
            if(s[i - 1] == '1' && s[i] == '0')
                hand ~= h_count;
            if(s[i - 1] == '0' && s[i] == '1')
                stand ~= s_count;
        }
    }
    long h_diff, s_diff;
    if(hand.length > stand.length)
        h_diff = 1;
    else if(hand.length < stand.length)
        s_diff = 1;

    long handstand;
    foreach (i; iota(max(stand.length - k, 1)))
    {
        long tmp;
        tmp += hand[i + k + h_diff] - hand[i];
        tmp += stand[i + k + s_diff] - stand[i];
        handstand = max(tmp, handstand);
    }
    if(stand.length > 1)
        handstand.writeln();
    else
        writeln(0);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
