#include <bits/stdc++.h>
using namespace std;
bool pr[128][128];
int init(){
pr['+']['+']=0;pr['+']['-']=0;pr['+']['*']=1;pr['+']['/']=1;pr['+']['^']=1;pr['+']['(']=1;
pr['-']['+']=0;pr['-']['-']=0;pr['-']['*']=1;pr['-']['/']=1;pr['-']['^']=1;pr['-']['(']=1;
pr['*']['+']=0;pr['*']['-']=0;pr['*']['*']=0;pr['*']['/']=0;pr['*']['^']=1;pr['*']['(']=1;
pr['/']['+']=0;pr['/']['-']=0;pr['/']['*']=0;pr['/']['/']=0;pr['/']['^']=1;pr['/']['(']=1;
pr['(']['+']=1;pr['(']['-']=1;pr['(']['*']=1;pr['(']['/']=1;pr['(']['^']=1;pr['(']['(']=1;
pr['@']['+']=1;pr['@']['-']=1;pr['@']['*']=1;pr['@']['/']=1;pr['@']['^']=1;pr['@']['(']=1;
return 0;
}
int main(){
freopen ("calc.in","r",stdin);freopen ("calc.out","w",stdout);
init();
stack<int>st;
stack<char>fh;
string a;
cin>>a;
int ans=0;
fh.push('@');
for (int i=0;i<a.length();i++){
if ('0'<=a[i]&&a[i]<='9'){
int num=0;
while('0'<=a[i]&&a[i]<='9'){
num*=10;num+=a[i]-'0';
i++;
}
st.push(num);
}
if (a[i]=='('){
fh.push(a[i]);
}
if (a[i]=='+'||a[i]=='-'||a[i]=='*'||a[i]=='/'||a[i]=='^'){
while(pr[fh.top()[a[i]]==0){
int x=st.top]();st.pop();
int y=st.top();st.pop();
int z=0;char t=fh.top();fh.pop();
if (t=='+')z=x+y;
if (t=='-')z=y-x;
if (t=='*')z=x*y;
if (t=='/')z=y/x;
if (t=='^')z=pow(y,x);
st.push(z);
}
fh.push(a[i]);
}
if (a[i]==')'){
char t=fh.top();fh.pop();
while(t!='('){
int x=st.top();st.pop();
int y=st.top();st.pop();
int z=0;
if (t=='+')z=x+y;
if (t=='-')z=y-x;
if (t=='*')z=x*y;
if (t=='/')z=y/x;
if (t=='^')z=pow(y,x);
st.push(z);
t=fh.top();fh.pop();
}
}
}
while(fh.top()!='@'){
int x=st.top();st.pop();
int y=st.top();st.pop();
int z=0;char t=fh.top();fh.pop();
if (t=='+')z=x+y;
if (t=='-')z=y-x;
if (t=='*')z=x*y;
if (t=='/')z=y/x;
if (t=='^')z=pow(y,x);
st.push(z);
}
cout<<st.top()<<endl;
return 0;
}