Scanf.sscanf (read_line ()) "%d %d" (fun n k ->
    let s = read_line () in
    let rec collect i count cur acc =
        if i < 0 then (
            let acc = count :: acc in
            if s.[0] = '0' then 0 :: acc else acc
        ) else (
            if s.[i] = cur then collect (i - 1) (count + 1) cur acc
                           else collect (i - 1) 1 s.[i] (count :: acc)
        )
    in
    let a = Array.of_list @@ collect (n - 1) 0 '1' [] in
    let al = Array.length a in
    (if Array.length a <= k * 2 + 1 then n else (
        let sum =
            let rec loop i acc =
                if i = k * 2 + 1 then acc else loop (i + 1) (acc + a.(i))
            in
            loop 0 0
        in
        let rec loop s b sum mx =
            if b = al - 1 then mx else
                let sum = sum + a.(b + 1) + a.(b + 2) - a.(s) - a.(s + 1) in
                loop (s + 2) (b + 2) sum (max mx sum)
        in
        loop 0 (k * 2) sum sum
    )) |> Printf.printf "%d\n"
)