import Control.Applicative ((<$>)) import Data.List main :: IO () main = do solve <$> getLine >>= print solve :: String -> Int solve s = g . foldl' f 200 $ ci where ci = findIndices (\x -> x == 'c') s wi = findIndices (\x -> x == 'w') s f d c = let wi' = dropWhile (< c) wi in if length wi' < 2 then d else min d (wi' !! 1 - c + 1) g x = if x == 200 then (-1) else x