#能过纯属运气,大致就是算括号,从小到大算起,先求小括号内部,再求中括号内部,再求大括号内部
a = input()
a = [i for i in a]for i in range(len(a)):
try:
if a[i].isdigit() and a[i+1].isdigit():
a[i] = a[i] + a[i+1]
a[i+1] = ' '
except:
break
while True:
try:
a.remove(' ')
except:
break
while True:
try:
n1 = a.index('(')
except:
break
for i in range(len(a))[n1+1:]:
if a[i] == '(':
n1 = i
elif a[i] == ')':
an = a[n1+1:i]
while True:
if '*' in an:
nw = an.index('*')
an[nw] = int(an[nw-1]) * int(an[nw+1])
an.pop(nw+1)
an.pop(nw-1)
elif '/' in an:
nw = an.index('/')
an[nw] = int(an[nw - 1]) / int(an[nw + 1])
an.pop(nw + 1)
an.pop(nw - 1)
else:
break
b = [an[0]]
for j in range(1, len(an)):
if an[j] == '-':
b[0] = int(b[0]) - int(an[j + 1])
elif an[j] == '+':
b[0] = int(b[0]) + int(an[j + 1])
while i > n1:
del a[i]
i -= 1
a[n1] = b[0]
break
while True:
try:
n1 = a.index('[')
except:
break
for i in range(len(a))[n1+1:]:
if a[i] == '[':
n1 = i
elif a[i] == ']':
an = a[n1+1:i]
while True:
if '*' in an:
nw = an.index('*')
an[nw] = int(an[nw-1]) * int(an[nw+1])
an.pop(nw+1)
an.pop(nw-1)
elif '/' in an:
nw = an.index('/')
an[nw] = int(an[nw - 1]) / int(an[nw + 1])
an.pop(nw + 1)
an.pop(nw - 1)
else:
break
while True:
if '+' in an:
nw = an.index('+')
an[nw] = int(an[nw-1]) + int(an[nw+1])
an.pop(nw+1)
an.pop(nw-1)
elif '-' in an:
nw = an.index('-')
an[nw] = int(an[nw - 1]) - int(an[nw + 1])
an.pop(nw + 1)
an.pop(nw - 1)
else:
break
while i > n1:
del a[i]
i -= 1
a[n1] = an[0]
break
while True:
try:
n1 = a.index('{')
except:
break
for i in range(len(a))[n1+1:]:
if a[i] == '{':
n1 = i
elif a[i] == '}':
an = a[n1+1:i]
while True:
if '*' in an:
nw = an.index('*')
an[nw] = int(an[nw-1]) * int(an[nw+1])
an.pop(nw+1)
an.pop(nw-1)
elif '/' in an:
nw = an.index('/')
an[nw] = int(an[nw - 1]) / int(an[nw + 1])
an.pop(nw + 1)
an.pop(nw - 1)
else:
break
while True:
if '+' in an:
nw = an.index('+')
an[nw] = int(an[nw-1]) + int(an[nw+1])
an.pop(nw+1)
an.pop(nw-1)
elif '-' in an:
nw = an.index('-')
an[nw] = int(an[nw - 1]) - int(an[nw + 1])
an.pop(nw + 1)
an.pop(nw - 1)
else:
break
while i > n1:
del a[i]
i -= 1
a[n1] = an[0]
break
while True:
if '*' in a:
nw = a.index('*')
a[nw] = int(a[nw - 1]) * int(a[nw + 1])
a.pop(nw + 1)
a.pop(nw - 1)
elif '/' in a:
nw = a.index('/')
a[nw] = int(a[nw - 1]) / int(a[nw + 1])
a.pop(nw + 1)
a.pop(nw - 1)
else:
break
b = [a[0]]
for i in range(1, len(a)):
if a[i] == '-':
b[0] = int(b[0]) - int(a[i+1])
elif a[i] == '+':
b[0] = int(b[0]) + int(a[i + 1])
print(b[0])