#include <cctype>
#include <iostream>
#include <map>
#include <string>
#include <unordered_map>
#include <stack>
using namespace std;
unordered_map<char, int> m{
{'#',0},{'$',1},{'(',1},{'+',2},{'-',2},{'*',3},{'/',3}
};
int calculate(int a,int b,char c);
string preprocess(string &str1);
int main()
{
string m_expresion;
while(cin>>m_expresion)
{
m_expresion=preprocess(m_expresion);
m_expresion.push_back('$');
stack<char> ops;ops.push('#');
stack<int> nums;
string donum;
for(int i=0;i<m_expresion.size(); )
{
if(isdigit(m_expresion[i]))
{
donum.push_back(m_expresion[i]);
++i;
}
else
{
if(donum!="")
{
nums.push(stoi(donum));
donum="";
}
if(m_expresion[i]==')')
{
if(ops.top()!='(')
{
int nums2=nums.top();nums.pop();
int nums1=nums.top();nums.pop();
char op=ops.top();ops.pop();
int ans=calculate( nums1, nums2, op);
nums.push(ans);
}
else
{
++i;
ops.pop();
}
}
else if(m_expresion[i]=='(')
{
ops.push('(');
++i;
}
else if(m[ops.top()]<m[m_expresion[i]])
{
ops.push(m_expresion[i]);
++i;
}
else
{
int nums2=nums.top();nums.pop();
int nums1=nums.top();nums.pop();
char op=ops.top();ops.pop();
int ans=calculate( nums1, nums2, op);
nums.push(ans);
}
}
}
cout<<nums.top();
}
}
int calculate(int a,int b,char c)
{
switch(c)
{
case '+':
return a+b;
case '-':
return a-b;
case '*':
return a*b;
case '/':
return a-b;
}
return 0;
}
string preprocess(string &str1)
{
if(str1[0]=='-')
{
str1="0"+str1;
}
for(int i=1;i<str1.size();++i)
{
if(
str1[i-1]=='('&&
str1[i]=='-'
)
{
str1.insert(i,1,'0');
}
}
return str1;
}
// 64 位输出请用 printf("%lld")