open Scanf
open Printf

let (n,k) = sscanf (read_line ()) "%d %d" (fun x y -> (x,y));;
let str = sscanf (read_line ()) "%s" (fun x -> x);;

let string2cnt_array s =
  let len = String.length s in
  let array = Array.make len (0,'0') in
  let rec loop i c num cnt =
    if (i = len) then
      let () = array.(num) <- (cnt,c) in
      let ret = Array.make (num+1) (0,'0') in
      let () = Array.blit array 0 ret 0 (num+1) in
      ret
    else if (s.[i] = c) then
      loop (i+1) c num (cnt+1)
    else
      let () = array.(num) <- (cnt,c) in
      loop (i+1) (s.[i]) (num+1) 1
    in loop 0 s.[0] 0 0;;


let cnt_array = string2cnt_array str;;
let len = Array.length cnt_array;;
let ruiseki = Array.make len 0;;
let () = ruiseki.(0) <- fst cnt_array.(0) in
for i = 1 to len - 1 do
  ruiseki.(i) <- ruiseki.(i-1) + (fst cnt_array.(i))
done

let rec solve i ans =
  if i = len then ans
  else
    let num = if snd cnt_array.(i) = '0' then 0 else 1 in
    let target = 2 * k - (1 - num) + i in
    let si = min (len - 1) target in
    let ruiseki_minus = if i = 0 then 0 else ruiseki.(i-1) in
    let next_ans = max ans (ruiseki.(si) - ruiseki_minus) in
    solve (i+1) next_ans;;

printf ("%d\n") (solve 0 0);;