#include<bits/stdc++.h>
#define int long long
using namespace std;
int f(char op){
if(op=='+'||op=='-'){
return 1;
}
else if(op=='*'||op=='/'){
return 2;
}
else if(op=='^'){
return 3;
}
else{
return 0;
}
}
int ff(int a,int b,char op){
if(op=='+'){
return a+b;
}
else if(op=='-'){
return a-b;
}
else if(op=='*'){
return a*b;
}
else if(op=='/'){
return a/b;
}
else if(op=='^'){
return pow(a,b);
}
else{
return 0;
}
}
int st(const string&s){
stack<int> q;
stack<char> ss;
for(int i=0;i<s.size();i++){
if(s[i]==' ')
continue;
else if(isdigit(s[i])){
int ans=0;
while(i<s.size()&&isdigit(s[i])){
ans=(ans*10)+(s[i]-'0');
i++;
}
i--;
q.push(ans);
}
else if(s[i]=='('){
ss.push(s[i]);
}
else if(s[i]==')'){
while(ss.empty()==0&&ss.top()!= '('){
int b=q.top();
q.pop();
int a=q.top();
q.pop();
char op=ss.top();
ss.pop();
q.push(ff(a,b,op));
}
if(ss.empty()==0)
ss.pop();
}
else{
while(ss.empty()==0&&f(ss.top())>=f(s[i])){
int b=q.top();
q.pop();
int a=q.top();
q.pop();
char op=ss.top();
ss.pop();
q.push(ff(a,b,op));
}
ss.push(s[i]);
}
}
while(ss.empty()==0){
int b=q.top();
q.pop();
int a=q.top();
q.pop();
char op=ss.top();
ss.pop();
q.push(ff(a,b,op));
}
return q.top();
}
signed main(){
string s;
getline(cin,s);
cout<<st(s)<<endl;
return 0;
}