import Data.List

main = interact $ sol . last . lines

sol s = s0 ++ s ++ s1 where
  (b,m) = foldl' f (0,0) s
  s0 = replicate (-m) '('
  s1 = replicate (max 0 (b-m)) ')'

f (b,m) '(' = (b+1,m)
f (b,m) ')' = (b-1,min m (b-1))