#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdlib>
using namespace std;
/*
int parse(string input)
{
while(input.find('(')!=string::npos)
{
int start;
int len;
start = input.find('(');
stack<char> brackets;
brackets.push('(');
for(int i=start+1;i<input.length()+1;i++)
{
if (input[i]=='(') brackets.push('(');
if (input[i]==')') brackets.pop();
if (brackets.empty()) { len = start-i; break; }
}
string inbrackets;
input.copy(inbrackets,start+1,len-1);
input.replace(start,len,atoi(parse(inbrackets)));
}
}*/
struct lexem
{
string lex;
string type;
};
queue<lexem> split_to_lexems(string input)
{
queue<lexem> series;
string lex;
int dgt=0,opr=0,min=0;;
for(int i=0;i<input.length();i++)
{
if (!dgt&&!opr)
{
if (isdigit(input[i]))
{
dgt=1;
lex=input[i];
}
else if(input[i]=='(' || input[i]==')')
{
lex = input[i];
lexem l;
l.lex = lex;
l.type="bracket";
series.push(l);
lex.clear();
}
else
{
opr=1;
lex=input[i];
}
}
else if(dgt)
{
if (isdigit(input[i]))
{
lex+=input[i];
}
else
{
if (min) { lex="-"+lex; min=0; }
lexem l;
l.lex = lex;
l.type = "number";
series.push(l);
lex.clear();
dgt=0;
i-=1;
}
}
else if(opr)
{
if (isdigit(input[i]) || input[i]=='(' || input[i]==')')
{
opr=0;
lexem l;
l.type = "operation";
if (lex.length()>1 && lex[0]=='-')
{
min=1;
lex.erase(0,1);
l.lex=lex;
series.push(l);
}
else if (lex.length()>1 && lex[lex.length()-1]=='-')
{
min=1;
lex.erase(lex.length()-1,1);
l.lex=lex;
series.push(l);
}
else { l.lex = lex; series.push(l); }
lex.clear();
i-=1;
}
else
{
lex+=input[i];
}
}
}
if (lex.length())
{
lexem l;
l.lex = lex;
if (dgt) { l.type="number";
if (min) l.lex="-"+l.lex; }
else if(opr) l.type="operation";
else l.type="bracket";
series.push(l);
}
return series;
}
queue<lexem> to_postfix(queue<lexem> series)//string input)
{
map<string,int> prior;
prior["+"]=0;
prior["-"]=0;
prior["*"]=1;
prior["/"]=1;
prior["^"]=2;
//queue<lexem> series = split_to_lexems(input);
queue<lexem> output;
stack<lexem> stk;
while(series.size())
{
if (series.front().type=="number")
{
output.push(series.front());
series.pop();
}
else if (series.front().type=="bracket")
{
if (series.front().lex=="(")
{
stk.push(series.front());
series.pop();
}
else if (series.front().lex==")")
{
while (!(stk.top().type=="bracket"))
{
output.push(stk.top());
stk.pop();
}
stk.pop();
//if (stk.top().lex=="(") {cout << stk.size() << endl; stk.pop(); }
//stk.pop();
//if(!stk.empty()) stk.pop();
series.pop();
}
}
else if (series.front().type=="operation")
{
while (!stk.empty() &&
prior[stk.top().lex]>=prior[series.front().lex]
&& stk.top().type=="operation")
{
output.push(stk.top());
stk.pop();
}
stk.push(series.front());
series.pop();
}
else series.pop();
}
while (!stk.empty())
{
output.push(stk.top());
stk.pop();
}
return output;/*
while (!output.empty())
{
cout << output.front().lex << " ";
output.pop();
}
cout << endl;
return series.size();*/
}
int add(int a, int b)
{ return a+b; }
int sub(int a, int b)
{ return a-b; }
int fdiv(int a, int b)
{ return a/b; }
int mul(int a, int b)
{ return a*b; }
int calc(string input)
{
map<string,int(*)(int,int)> ops;
ops["+"]=add;
ops["-"]=sub;
ops["*"]=mul;
queue<lexem> series = to_postfix(split_to_lexems(input));
stack<int> result;
while (series.size())
{
if (series.front().type=="number")
{
result.push(atoi(series.front().lex.c_str()));
series.pop();
}
else if (series.front().type=="operation")
{
int op1 = result.top();
result.pop();
int op2 = result.top();
result.pop();
result.push(ops[series.front().lex](op2,op1));
series.pop();
}
}
return result.top();
}
/*
int count(string input)
{
map<string,int> priority;
priority["+"]=0;
priority["-"]=0;
priority["*"]=1;
priority["/"]=1;
stack<op> operands;
stack<oper> operations;
int pos = 0;
while (pos<input.length())
{
int op =0;
while (isdigit(input[pos]))
{
op*=10;
op+=input[pos++]-48;
}
operands.push(op);
if (pos<input.length())
{
operations.push(input[pos++]);
}
}
int res=0;
//while (!operands.empty()) { cout<<operands.top() << " "; operands.pop(); }
//cout << endl;
//while (!operations.empty()) { cout<<operations.top() << " "; operations.pop(); }
while (!operations.empty())
{
char op = operations.top();
operations.pop();
int op1=operands.top();
operands.pop();
int op2=operands.top();
operands.pop();
switch(op)
{
case '+':
operands.push(op1+op2);
break;
case '-':
operands.push(op1-op2);
break;
case '*':
operands.push(op1*op2);
break;
}
}
return operands.top();
}*/
int main()
{
string input;
while (getline(cin,input))
{
cout << calc(input) << endl;
}
}