"use strict"
function main(arg) {
    const N = arg.split("\n")[0].split(" ").map((x)=>{return parseInt(x)})[0]
    const K = arg.split("\n")[0].split(" ").map((x)=>{return parseInt(x)})[1]
    const S = arg.split("\n")[1].split("").map((x)=>{return parseInt(x)})

    console.log(search(S, 0, N, K))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function search(S, i, N, K){
    let start = i, cnt = 0, mode = 1, ans = -1
    while(i < N){
        //console.log(`cnt:${cnt}\ni:${i}\nans:${ans}\n`)
        switch(S[i]){
            case 0:
                if (mode == 1){
                    if (K == cnt) return (ans>(i - start))?ans:i-start
                    ++cnt
                    mode = 0
                }
                break;
            case 1:
                if (mode == 0 && cnt == 1) ans = search(S, i, N, K)
                mode = 1
                break;
        }
        ++i
    }
    return i-start
}