import re while 1:a=re.sub("(\D|$)",")\\1",input());exec("print"+"("*a.count(")")+a)