let analysis area =
  let len = String.length area in
  let stack = Stack.create () in
  let rec loop acc = function
      i when i = len -> acc
    | i ->
      match area.[i] with
      | '\\' -> Stack.push i stack; loop acc (i+1)
      | '/' -> loop
                 (match Stack.is_empty stack with
                    true -> acc
                  | false -> let j = Stack.pop stack in
                    (((j,i),i-j)::acc))
                 (i+1)
      | _ -> loop acc (i+1)
  in loop [] 0
 
let summarize lst =
  let rec loop acc = function
      []  -> acc
    | [x] -> x::acc
    | ((s1,e1),v1)::((s2,e2),v2)::r when s1 < s2 && e1 > e2 ->
      loop acc (((s1,e1), v1+v2)::r)
    | a::(b::r as rest) -> loop (a::acc) rest
  in loop [] lst
 
let () =
  let line = read_line () in
  let count = ref 0 in
  let buf = Buffer.create 128 in
  analysis line |> summarize
  |> List.fold_left
    (fun acc (_,v) ->
       incr count;
       Buffer.add_string buf (Printf.sprintf " %d" v);
       acc+v)
    0
  |> (fun sum -> Printf.printf "%d\n%d%s\n" sum !count (Buffer.contents buf))