#include <fstream>
#include <unordered_map>
#include <stack>
using namespace std;
ifstream fin("evaluare.in");
ofstream fout("evaluare.out");
string expr;
stack<int> st1;
stack<char> st2;
unordered_map<char, int> pr;
int numar(string& expr, int& i) {
int nr = 0;
while (expr[i] >= '0' && expr[i] <= '9') {
nr = nr * 10 + expr[i] - '0';
i++;
}
i--;
return nr;
}
int operatie(int a, char op, int b) {
if (op == '+')
return a + b;
if (op == '-')
return a - b;
if (op == '*')
return a * b;
return a / b;
}
void calcul(stack<int>& st1, stack<char>& st2) {
int b = st1.top();
st1.pop();
int a = st1.top();
st1.pop();
st1.push(operatie(a, st2.top(), b));
st2.pop();
}
int main() {
pr['('] = 0;
pr['+'] = pr['-'] = 1;
pr['*'] = pr['/']= 2;
fin >> expr;
for (int i = 0; i < expr.size(); i++)
if (expr[i] >= '0' && expr[i] <= '9')
st1.push(numar(expr,i));
else
if (expr[i] == '(')
st2.push('(');
else
if (expr[i] == ')') {
while (st2.top() != '(')
calcul(st1, st2);
st2.pop();
}
else {
while (!st2.empty() && pr[st2.top()] >= pr[expr[i]])
calcul(st1, st2);
st2.push(expr[i]);
}
while (!st2.empty())
calcul(st1, st2);
fout << st1.top();
return 0;
}