#include <bits/stdc++.h>
using namespace std;
stack<int> k;
stack<int> t;
string s;
void ca(){
int y=t.top();
t.pop();
int x=t.top();
t.pop();
if(k.top()=='+') t.push(x+y);
if(k.top()=='-') t.push(x-y);
if(k.top()=='*') t.push(x*y);
if(k.top()=='/') t.push(x/y);
else{
int cnt=1;
for(int i=1;i<=y;i++){
cnt*=x;
}
t.push(cnt);
}
}
int qwq(char p){
if(p=='+'||p=='-') return 1;
else if(p=='*'||p=='/') return 2;
else if(p=='^') return 3;
else return 0;
}
int main(){
int sum=0;
k.push(0);
cin>>s;
s[s.size()]=')';
int l=s.size();
for(int i=0;i<l;i++){
if(s[i]<='9'&&s[i]>='0'){
sum=sum*10+(s[i]-'0');
}
else{
if(s[i]=='('){
k.push(0);
}
else if(s[i]==')'){
while(k.top()!='('){
ca();
}
}
else{
int num=qwq(s[i]);
if(num<=k.top()){
while(num<=k.top()){
ca();
}
}
k.push(num);
}
t.push(sum);
sum=0;
}
}
return 0;
}
玄关玄关