fun main(args :Array<String>) {
    val (n, k) = readIntegerList()
    val s = readLine()!!
    val tmp = arrayListOf<Int>()
    var pre = s[0]
    var count = 1
    for (c in s.substring(1)) {
        if (pre == c) {
            count++
        } else {
            tmp.add(count)
            count = 1
        }

        pre = c;
    }
    tmp.add(count)

    if (s[0] == '0') {
        tmp.add(0, 0)
    }
    if (s.last() == '0') {
        tmp.add(0)
    }
    // println(tmp)
    var max = tmp
        .subList(0, Math.min(2 * k + 1, tmp.size))
        .sum()
    var a = max
    // println(a)
    for (i in 2 until tmp.size - (2 * k) step 2) {
        a = a - tmp[i - 1] - tmp[i - 2] + tmp[i + 2 * k - 1] + tmp[i + 2 * k]
        // println("${i - 2} ${i + 2 * k} ${a}")
        max = Math.max(max, a)
    }
    println(max)
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
