let () = let s = read_line () in let n = String.length s in let rec doit i c w = if i = n then c, w else begin if s.[i] = 'c' then if c <> (-1) then doit (i + 1) c w else doit (i + 1) i w else if s.[i] = 'w' then if c = (-1) then doit (i + 1) c w else match w with | [] -> doit (i + 1) c (i :: w) | [_] -> c, i :: w | _ -> assert false else doit (i + 1) c w end in let (c, w) = doit 0 (-1) [] in let n = if c = (-1) then (-1) else match w with | [] | [_] -> (-1) | [w; _] -> if c >= w then (-1) else w - c + 1 | _ -> assert false in Printf.printf "%d\n" n