#include <bits/stdc++.h>
#define LL long long
using namespace std;
char c[2000005];
stack<char> op;
queue<char> s;
stack<LL> T;
LL JS(queue<char> s, stack<LL> T) {
while(!s.empty()) {
//将队列中的数据依次出队,然后压栈
if(s.front()>='0'&&s.front()<='9') {
LL t=0;
while(!s.empty()&&s.front()>='0'&&s.front()<='9') {
t=t*10+s.front()-'0';
s.pop();
}
s.pop();//数字结束。pop空格
T.push(t);
} else {
//在出队的过程中如果遇到运算符,则从栈中弹出2个运算数,分别作为右运算数和左运算数,进行运算;
//步骤2的运算结果入栈;
LL ans1=T.top();
T.pop();
LL ans2=T.top();
T.pop();
if(s.front()=='*') {
T.push(ans2*ans1);
}
if(s.front()=='/') {
T.push(ans2/ans1);
}
if(s.front()=='+') {
T.push(ans2+ans1);
}
if(s.front()=='-') {
T.push(ans2-ans1);
}
s.pop();
}
}
LL ans=T.top();
T.pop();
return ans;
}
int main() {
scanf("%s", c+1);
LL n=strlen(c+1);
for(LL i=1; i<=n; i++) {
if(c[i]==' ') { //空格
continue;
}
//若读取的是操作数 将该操作数存入操作数堆栈
if('0'<=c[i]&&c[i]<='9') {
while('0'<=c[i]&&c[i]<='9') {
s.push(c[i]);
i++;
}
s.push(' ');//多加空格表示一个数字结束
i--;
} else {
//该运算符为左括号"(",则直接存入运算符堆栈。
if(c[i]=='(') {
op.push(c[i]);
continue;
}
//该运算符为右括号")",则输出运算符堆栈中的运算符到操作数堆栈,直到遇到左括号为止。
if(c[i]==')') {
while(!op.empty()&&op.top()!='(') {
s.push(op.top());
op.pop();
}
op.pop();
continue;
}
//若运算符堆栈栈顶的运算符为括号,则直接存入运算符堆栈。
if(op.empty()||op.top()=='(') {
op.push(c[i]);
continue;
}
//若比运算符堆栈栈顶的运算符优先级高,则直接存入运算符堆栈
if(op.empty()||((c[i]=='*'||c[i]=='/')&&(op.top()=='+'||op.top()=='-'))) {
op.push(c[i]);
continue;
}
//若比运算符堆栈栈顶的运算符优先级低或者相等,
//则输出栈顶运算符到操作数堆栈,并将当前运算符压入运算符堆栈。
while(!op.empty()&&!((c[i]=='*'||c[i]=='/')&&(op.top()=='+'||op.top()=='-'))&&op.top()!='(') {
s.push(op.top());
op.pop();
}
op.push(c[i]);
}
}
//当表达式读取完成后运算符堆栈中尚有运算符时,
//则依序取出运算符到操作数堆栈,直到运算符堆栈为空。
while(!op.empty()) {
s.push(op.top());
op.pop();
}
// while(!s.empty()){
// cout<<s.front();
// s.pop();
// }
// cout<<endl;
printf("%lld\n", JS(s, T));
return 0;
}