let read () = 
  let rec iter n =
    if n = 0 then []
    else let arr = Array.of_list @@ List.map int_of_string @@ Str.split (Str.regexp "") (read_line ()) in
         arr :: iter (n - 1) in
  Array.of_list @@ iter 12
       
let rec iteri s t f = if s > t then () else begin f s; iteri (s + 1) t f end

let solve arr =
  let rec remove x y =
    if x >= 0 && x <= 11 && y >= 0 && y <= 11 && arr.(x).(y) = 1 then 
      begin
        arr.(x).(y) <- 0;
        remove (x+1) y;
        remove (x-1) y;
        remove x (y+1);
        remove x (y-1)
      end
    else () in
  let cnt = ref 0 in
  iteri 0 11 (fun i -> iteri 0 11 (fun j -> if arr.(i).(j) = 1 then begin incr cnt; remove i j end else ()));
  !cnt

let _ = 
  let rec loop () =
    let arr = read () in
    Printf.printf "%d\n" @@ solve arr;
    ignore @@ read_line ();
    loop ()
  in try loop () with End_of_file -> ()