#include <stdio.h>
#include <string.h>
#define MAX_S 100000
char s[MAX_S];
int n;
int sIndex;
char operators[MAX_S];
int operatorsSize;
int factors[MAX_S];
int factorsSize;
int priority(char op) {
if (op=='*' || op=='/')
return 2;
if (op=='+' | op=='-')
return 1;
return 0;
}
void pushOperator(char op) {
if (op=='*' || op=='/' || op=='+' || op=='-' || op=='(' || op==')')
operators[operatorsSize++] = op;
}
char popOperator() {
return operatorsSize ? operators[--operatorsSize] : '\0';
}
char topOperator() {
return operatorsSize ? operators[operatorsSize - 1] : '\0';
}
bool hasOperators() {
return operatorsSize>0;
}
void pushFactor(int factor) {
factors[factorsSize++]=factor;
}
int popFactor() {
return factorsSize ? factors[--factorsSize] : 0;
}
int compute(int a, int b, char op) {
int result;
result = 0;
if (op=='*')
result=a*b;
else if(op=='/')
result=a/b;
else if(op=='+')
result=a+b;
else if(op=='-')
result=a-b;
return result;
}
void computeTop() {
int a,b;
b=popFactor();
a=popFactor();
pushFactor(compute(a,b,popOperator()));
}
int factor() {
int number;
number=0;
while(s[sIndex]>='0' && s[sIndex]<='9') {
number=number*10+s[sIndex]-'0';
sIndex++;
}
return number;
}
int main() {
FILE *fin, *fout;
fin=fopen("evaluare.in","r");
fout=fopen("evaluare.out","w");
fgets(s,MAX_S,fin);
n=strlen(s);
sIndex=0;
while(sIndex<n) {
if(s[sIndex]>='0' && s[sIndex]<='9')
pushFactor(factor());
else if(s[sIndex]=='(')
pushOperator(s[sIndex++]);
else if(s[sIndex] ==')') {
while(topOperator()!='(')
computeTop();
popOperator();
sIndex++;
} else if(priority(s[sIndex])) {
while(priority(topOperator()) && priority(topOperator())>=priority(s[sIndex]))
computeTop();
pushOperator(s[sIndex++]);
} else
sIndex++;
}
while(hasOperators())
computeTop();
fprintf(fout,"%d\n",popFactor());
fclose(fin);
fclose(fout);
return 0;
}