Question and Answer from L4-M1
s = input()
stack = []
remove = set()
for i, ch in enumerate(s):
if ch == '(':
stack.append(i)
elif ch == ')':
if stack:
stack.pop()
else:
remove.add(i)
remove.update(stack)
result = ""
for i in range(len(s)):
if i not in remove:
result += s[i]
print(result)