def solve(string):

    n, k, s = string.split()

    n, k = list(map(int, [n, k]))

    flip = [0]

    for i, (s0, s1) in enumerate(zip(s, s[1:]), start=1):

        if s0 != s1:

            flip.append(i)

    flip += [n]

    return str(

        max([

            flip[min(len(flip) - 1, i + 2 * k + (i % 2 ^ int(s[0])))] - flip[i]

            for i in range(len(flip))

        ]))





if __name__ == '__main__':

    print((solve('\n'.join([eval(input()), eval(input())]))))

def solve(string):

    n, k, s = string.split()

    n, k = list(map(int, [n, k]))

    flip = [0]

    for i, (s0, s1) in enumerate(zip(s, s[1:]), start=1):

        if s0 != s1:

            flip.append(i)

    flip += [n]

    start = int(s[0])

    l = len(flip) - 1

    return str(max([flip[min(l, i + 2 * k + (i % 2 ^ start))] - flip[i] for i in range(l + 1)]))





if __name__ == '__main__':

    print((solve('\n'.join([eval(input()), eval(input())]))))

def solve(string):
    n, k, s = string.split()
    n, k = list(map(int, [n, k]))
    flip = [0]
    for i, (s0, s1) in enumerate(zip(s, s[1:]), start=1):
        if s0 != s1:
            flip.append(i)
    flip += [n]
    return str(
        max(
            [
                flip[min(len(flip) - 1, i + 2 * k + (i % 2 ^ int(s[0])))] - flip[i]
                for i in range(len(flip))
            ]
        )
    )


if __name__ == "__main__":
    print((solve("\n".join([eval(input()), eval(input())]))))

def solve(string):
    n, k, s = string.split()
    n, k = list(map(int, [n, k]))
    flip = [0]
    for i, (s0, s1) in enumerate(zip(s, s[1:]), start=1):
        if s0 != s1:
            flip.append(i)
    flip += [n]
    start = int(s[0])
    l = len(flip) - 1
    return str(
        max([flip[min(l, i + 2 * k + (i % 2 ^ start))] - flip[i] for i in range(l + 1)])
    )


if __name__ == "__main__":
    print((solve("\n".join([eval(input()), eval(input())]))))

+    start = int(s[0]) +    l = len(flip) - 1 -        max( -            [ -                flip[min(len(flip) - 1, i + 2 * k + (i % 2 ^ int(s[0])))] - flip[i] -                for i in range(len(flip)) -            ] -        ) +        max([flip[min(l, i + 2 * k + (i % 2 ^ start))] - flip[i] for i in range(l + 1)])