fun main(args: Array<String>) = ripPro0408e()

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

    var left = 0
    var right = 0
    var stand = 0
    var answer = 0
    while (left <= s.lastIndex) {
        while (stand < k) {
            while (right <= s.lastIndex && stand <= k && s[right]) right++
            while (right <= s.lastIndex && stand <= k && !s[right]) right++
            while (right <= s.lastIndex && stand <= k && s[right]) right++
            stand++
        }
        answer = Math.max(answer, right - left)

        while (left <= s.lastIndex && s[left]) left++
        while (left <= s.lastIndex && !s[left]) left++
        stand--

    }

    println(answer)
}
