function main(input) {
    var N = input.split("\n")[0].split(" ")[0];
    var K = input.split("\n")[0].split(" ")[1];
    var S = input.split("\n")[1];
    S = S.trim();
    var Sr = S.trim().split('').reverse().join('');
    for (var n = 0; n < K; n++) {
        var ss = S.match(/1+0+1+/g)
        if (ss != null) {
            ss = ss.reduce((a, c) => a.length > c.length ? a : c)
        } else {
            ss = ""
        }
        var srs = Sr.match(/1+0+1+/g)
        if (srs != null) {
            srs = srs.reduce((a, c) => a.length > c.length ? a : c)
        } else {
            srs = ""
        }
        var r = ""
        if (ss.length > srs.length) {
            S = S.replace(ss, ss.split('').map(a => "1").join(''))
        } else {
            S = Sr.replace(srs, srs.split('').map(a => "1").join('')).split('').reverse().join('');
        }

        Sr = S.trim().split('').reverse().join('');
    }
    console.log(S.match(/1+/g).reduce((a, c) => a.length > c.length ? a : c).length)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));