#include<stdio.h>
#include<stdlib.h>
int precedence(char c)
{
if(c=='*'||c=='/')
return 2;
if(c=='+'||c=='-')
return 1;
return 0;
}
int main()
{
char stack1[1000]; int top_index1=-1;
char stack2[1000]; int top_index2=-1;
char c;
while(1)
{
scanf("%c",&c);
if(c=='\n')
break;
else if(c>='0'&&c<='9')
{
top_index2++;
stack2[top_index2]=c;
}
else if(c=='(')
{
top_index1++;
stack1[top_index1]=c;
}
else if(c==')')
{
while(stack1[top_index1]!='(')
{
top_index2++;
stack2[top_index2]=stack1[top_index1];
top_index1--;
}
top_index1--;
}
else if(c=='+'||c=='-'||c=='*'||c=='/')
{
if(top_index1==-1||precedence(c)>precedence(stack1[top_index1]))
{
top_index1++;
stack1[top_index1]=c;
}
else
{
while(top_index1>=0&&precedence(stack1[top_index1])>=precedence(c))
{
top_index2++;
stack2[top_index2]=stack1[top_index1];
top_index1--;
}
top_index1++;
stack1[top_index1]=c;
}
}
}
while(top_index1!=-1)
{
top_index2++;
stack2[top_index2]=stack1[top_index1];
top_index1--;
}
// printf("%s\n",stack2); printf("%d\n",top_index2);
int stack3[1000]; int top_index3=-1;
for(int i=0;i<=top_index2;i++)
{
if(stack2[i]>='0'&&stack2[i]<='9')
{
top_index3++;
stack3[top_index3]=stack2[i]-48;
continue;
}
else
{
if(stack2[i]=='+')
{
int t1=stack3[top_index3];
int t2=stack3[top_index3-1];
top_index3--;
stack3[top_index3]=t1+t2;
}
if(stack2[i]=='-')
{
int t1=stack3[top_index3];
int t2=stack3[top_index3-1];
top_index3--;
stack3[top_index3]=t2-t1;
}
if(stack2[i]=='*')
{
int t1=stack3[top_index3];
int t2=stack3[top_index3-1];
top_index3--;
stack3[top_index3]=t1*t2;
}
if(stack2[i]=='/')
{
int t1=stack3[top_index3];
int t2=stack3[top_index3-1];
top_index3--;
stack3[top_index3]=t2/t1;
}
}
}
printf("%d",stack3[0]);
}