fun main(args: Array<String>) {
    abc124d()
}

fun abc124d() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!.map { it == '1' }.toBooleanArray()

    val list = mutableListOf(s[0] to 1)

    for (i in 1 until n) {
        if (s[i] == s[i - 1]) {
            list[list.lastIndex] = list[list.lastIndex].first to list[list.lastIndex].second + 1
        } else {
            list.add(s[i] to 1)
        }
    }

    val cSum = IntArray(list.size + 1)
    for (i in 0 until list.size) cSum[i + 1] = cSum[i] + list[i].second

    val answer = list.mapIndexed { index, pair ->
        val take = 2 * k + if (pair.first) 1 else 0
        val takeIndex = Math.min(cSum.lastIndex, index + take)
        cSum[takeIndex] - cSum[index]
    }.max()!!

    println(answer)
}
