import java.util.*
import java.math.*
fun main(args: Array<String>) {

    val (N, K) = readLine()!!.split(" ").map(String::toInt)

    if (2 * K + 1 >= N) {
        print(N)
        return
    }
    var n = 0
    var isOder = false
    var ans = 0
    var tmp = IntArray(N){0}
    var from = 0
    var to = 0
    var tmpn = 0
    var k = K

    for (c in readLine()!!) {
        if (isOder) {
            if (c == '1') {
                isOder = false

                k--
                tmp[to++] = n
                tmpn += n

                n = 0
            }
            n++
        } else {
            if (c == '0') {
                isOder = true

                tmp[to++] = n
                tmpn += n
                if (k == 0) {
                    //println(tmp)
                    ans = Math.max(ans, tmpn)
                    tmpn -= tmp[from++] + tmp[from++]
                    k++
                }

                n = 0
            }
            n++
        }
    }
    if (n != 0) {
        //print(tmp)
        ans = Math.max(ans, tmpn+n)
    }


    //println(list)
    println(ans)
}