#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
char arr[100040];
int pos;
int NumVal;
class Expr {
public:
virtual int calc() = 0;
};
class ExprNum :public Expr {
public:
int val;
ExprNum(int v) :val(v) {}
int calc() {
return val;
}
};
class ExprParen :public Expr {
public:
std::unique_ptr<Expr> expr;
ExprParen(unique_ptr<Expr> e) :expr(move(e)) {}
int calc() {
return expr->calc();
}
};
class ExprBinary :public Expr {
public:
char op;
unique_ptr<Expr> LHS, RHS;
ExprBinary(unique_ptr<Expr> l, unique_ptr<Expr> r, char p) :LHS(move(l)), RHS(move(r)), op(p) {}
int calc() {
if (op == '+')return LHS->calc() + RHS->calc();
if (op == '*')return LHS->calc() * RHS->calc();
if (op == '/')return LHS->calc() / RHS->calc();
if (op == '-')return LHS->calc() - RHS->calc();
return 0;
}
};
int getNextToken() {
if (isdigit(arr[pos])) {
NumVal = 0;
while (isdigit(arr[pos])) {
NumVal = NumVal * 10 + arr[pos] - '0';
pos++;
}
return -1;
}
else {
pos++;
return arr[pos - 1];
}
}
unique_ptr<Expr> ParseE();
unique_ptr<Expr> ParseT();
unique_ptr<ExprBinary> ParseE_();
unique_ptr<ExprBinary> ParseT_();
unique_ptr<Expr> ParseF();
unique_ptr<Expr> ParseE() {
auto LHS = ParseT();
auto RHS =ParseE_();
if (RHS != nullptr) {
unique_ptr<ExprBinary> ptr;
ptr = make_unique<ExprBinary>(ExprBinary(move(LHS), move(RHS->RHS), RHS->op));
auto cptr = (ExprBinary*)RHS->LHS.get();
while (cptr != nullptr) {
ptr = make_unique<ExprBinary>(ExprBinary(move(ptr), move(cptr->RHS), cptr->op));
cptr = (ExprBinary*)cptr->LHS.get();
}
return ptr;
}
else {
return LHS;
}
}
unique_ptr<ExprBinary> ParseE_() {
if (arr[pos] == '+' || arr[pos] == '-') {
char ch = getNextToken();
auto RHS = ParseT();
auto RRR = ParseE_();
return make_unique<ExprBinary>(ExprBinary(move(RRR), move(RHS), ch));
}
else {
return nullptr;
}
}
unique_ptr<Expr> ParseT() {
auto LHS = ParseF();
auto RHS = ParseT_();
if (RHS != nullptr) {
unique_ptr<ExprBinary> ptr;
ptr = make_unique<ExprBinary>(ExprBinary(move(LHS), move(RHS->RHS), RHS->op));
auto cptr = (ExprBinary*)RHS->LHS.get();
while (cptr != nullptr) {
ptr = make_unique<ExprBinary>(ExprBinary(move(ptr), move(cptr->RHS), cptr->op));
cptr = (ExprBinary*)cptr->LHS.get();
}
return ptr;
}
else {
return LHS;
}
}
unique_ptr<ExprBinary> ParseT_() {
if (arr[pos] == '*' || arr[pos] == '/') {
char ch = getNextToken();
auto RHS = ParseF();
auto RRR = ParseT_();
return make_unique<ExprBinary>(ExprBinary(move(RRR), move(RHS), ch));
}
else {
return nullptr;
}
}
unique_ptr<Expr> ParseF() {
if (arr[pos] == '(') {
getNextToken();
auto v = ParseE();
getNextToken();
return v;
}
else {
int val = 1;
if (arr[pos] == '-') {
val = -1;
pos++;
}
getNextToken();
return make_unique<ExprNum>(ExprNum(NumVal*val));
}
}
int main()
{
while (cin >> arr) {
pos = 0;
cout << ParseE()->calc() << endl;
}
}