let calc s k =
  if k = 0 then
    Array.fold_left (fun (v, w) (_, x) -> if x = '1' then max v (w+1), w+1 else v, 1) (0, 0) s |> fst else
  let t = Array.make 101010 0 in
  let ans, _, _, _, _ =
    Array.fold_left (fun (ans, cur, cs, ti, p) (i, x) ->
      match p, x with
      | '1', '1' -> (max ans (cur+1), cur+1, cs+1, ti, '1')
      | '0', '0' -> (max ans (cur+1), cur+1, cs+1, ti, '0')
      | '0', '1' -> begin
        t.(ti) <- cs;
        (max ans (cur+1), cur+1, 1, ti+1, '1')
      end
      | _ (* 1, 0 *) -> begin
        if ti < k then
          (max ans (cur+1), cur+1, cs+1, ti, '0')
        else
          (max ans (cur+1-t.(ti-k)), cur+1-t.(ti-k), cs+1, ti, '0')
      end) (0,0,0,0,'1') s
  in
  ans
let () =
  Scanf.scanf "%d %d %s" @@ fun n k s ->
  let s = Array.init n (fun i -> i, s.[i]) in
  max (calc s k) (calc (Array.map (fun (i, x) -> i, (if x = '0' then '1' else '0')) s) (k-1))
  |> Printf.printf "%d\n"
