while True:
try:
str_input = input()
str_input = str_input.replace('{', '(')
str_input = str_input.replace('[', '(')
str_input = str_input.replace('}', ')')
str_input = str_input.replace(']', ')')
result = eval(str_input)
print(int(result))
except:
break
try:
str_input = input()
str_input = str_input.replace('{', '(')
str_input = str_input.replace('[', '(')
str_input = str_input.replace('}', ')')
str_input = str_input.replace(']', ')')
result = eval(str_input)
print(int(result))
except:
break