import Data.List main = do cs <- getLine print $ compute cs compute cs = if null lens then -1 else head lens where lens = [ length as + length cs + 3 | ('c':xs) <- tails cs , let (as,bs) = break ('w' ==) xs , not $ null bs , let (cs,ds) = break ('w' ==) $ tail bs , not $ null ds ]