#include<iostream>#include<algorithm>#include<cstring>#include<stack>#include<unordered_map>usingnamespace std;
stack <int> num;
stack <char> op;//模板级的代码voidevil(){int b = num.top();num.pop();int a = num.top();num.pop();int x =0;char c = op.top();op.pop();if(c =='+') x = a + b;elseif(c =='-') x = a - b;elseif(c =='*') x = a * b;else x = a / b;
num.push(x);}usingnamespace std;int main (){
unordered_map<char,int> pr ={{'+',1},{'-',1},{'*',2},{'/',2}};
string str;
cin >> str;for(int i =0;i < str.size(); i++){char c = str[i];//把字符中的数字转换为整数if(isdigit(c)){int j = i,x =0;//判断的时候首先是判断是否在边界内while(j < str.size()&&isdigit(str[j])){
x = x *10+ str[j++]-'0';}
i = j -1;
num.push(x);}elseif(c =='(') op.push(c);//左括号进栈elseif(c ==')'){//当我们遇到右括号的时候,我们需要找到左括号while(op.top()!='(')evil();
op.pop();}else{//中缀的表达式 看优先级while(op.size()&& op.top()!='('&& pr[op.top()]>= pr[c])evil();
op.push(c);}}while(op.size())evil();
cout << num.top()<<'\n';return0;}