let (n, k) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n k -> (n, k)
let s = read_line () 
  |> Str.full_split (Str.regexp "0+") 
  |> List.map (function Str.Text s | Str.Delim s -> (s.[0], String.length s))

let rec take_sum que = function
  | 0 -> 0
  | n -> (snd @@ Queue.take que) + take_sum que (n - 1)

let rec loop ans sum k que = function
  | [] -> ans
  | (ch, cnt) as pair :: rest ->
      Queue.add pair que;
      let next_sum, next_k = 
        if ch = '1' then (sum + cnt, k)
        else if k = 0 then 
          let t = if fst (Queue.peek que) = '0' then 1 else 2 in
          (sum + cnt - take_sum que t, 0)
        else (sum + cnt, k - 1) in
    loop (max ans next_sum) next_sum next_k que rest

let () = Printf.printf "%d\n" @@ loop 0 0 k (Queue.create ()) s