import Control.Arrow import Data.List import qualified Data.ByteString.Char8 as B main = do s <- B.getLine let lrs = map (\ss -> if B.null ss || B.head ss /= '(' then (0,0) else (fst *** fst) (B.foldl parse ((0,""),(0,"")) ss)) (B.tails s) let left = sum (map fst lrs) let right = sum (map snd lrs) putStrLn $ unwords $ map show [left, right] parse ((nl,al),(nr,ar)) '(' = ((nl,al1),(nr,ar1)) where al1 = if null al then "(" else al ar1 = if null ar then "(" else ar parse ((nl,al),(nr,ar)) '^' = ((nl,al1),(nr,ar1)) where al1 = if elem al ["(","(^"] then al++"^" else al ar1 = if elem ar ["(*","(*^"] then ar++"^" else ar parse ((nl,al),(nr,ar)) '*' = ((nl,al1),(nr,ar1)) where al1 = if al == "(^^" then al++"*" else al ar1 = if ar == "(" then ar++"*" else ar parse ((nl,al),(nr,ar)) ')' = ((nl1,al1),(nr1,ar1)) where (nl1,al1) = if al == "(^^*" then (nl+1,al) else (nl,al) (nr1,ar1) = if ar == "(*^^" then (nr+1,ar) else (nr,ar)