#include <stdio.h>
#include <string.h>
#include <math.h>
#define MAX 1000
int numstack[1000];
int stack[1000];
char charstack[1000];
char equation[1000];
int numtop=0;
int chartop=0;
int top=0;
void convert();
void calculator(int type);
void convert()
{
int i;
for(i=0;i<strlen(equation);i++)
{
printf("------------------------------------------\n");
if(equation[i]>=48&&equation[i]<=57)
{
int temp=0;
while(equation[i]>=48&&equation[i]<=57)
{
stack[top++]=equation[i]-'0';
i++;
}
int cnt=0;
while(top>0)
{
temp+=(stack[top-1])*pow(10.0, cnt);
top--;
}
numstack[numtop++]=temp;
}
if(equation[i]<48||equation[i]>57)
{
if(equation[i]==')'||equation[i]=='}'||equation[i]==']')
calculator(1);
else
charstack[chartop++]=equation[i];
}/*for(int i=0;i<numtop;i++)
printf("%d ", numstack[i]);
printf("\n%d\n", numtop);
for(int i=0;i<chartop;i++)
printf("%c ", charstack[i]);
printf("\n%d\n", chartop);*/
}
calculator(0);
}
void calculator(int type)//괄호 계산은 1번 , 그냥 계산은 0번
{
if(type==1)
{
while(charstack[chartop-1]!='('||charstack[chartop-1]!='{'||charstack[chartop-1]!='[')
{
printf("debug\n");
int x, y;
int temp;
x=numstack[numtop-2];
y=numstack[numtop-1];
if(charstack[chartop-1]=='+')
{
temp=x+y;
numtop=numtop-2;
numstack[numtop++]=temp;
}
else if(charstack[chartop-1]=='-')
{
temp=x-y;
numtop=numtop-2;
numstack[numtop++]=temp;
}
else if(charstack[chartop-1]=='*')
{
temp=x*y;
numtop=numtop-2;
numstack[numtop++]=temp;
}
else if(charstack[chartop-1]=='/')
{
temp=x/y;
numtop=numtop-2;
numstack[numtop++]=temp;
}
chartop--;
}
chartop--;
}
if(type==0)
{
while(chartop>0)
{
int x, y;
int temp;
x=numstack[numtop-2];
y=numstack[numtop-1];
if(charstack[chartop-1]=='+')
{
temp=x+y;
numtop=numtop-2;
numstack[numtop++]=temp;
}
else if(charstack[chartop-1]=='-')
{
temp=x-y;
numtop=numtop-2;
numstack[numtop++]=temp;
}
else if(charstack[chartop-1]=='*')
{
temp=x*y;
numtop=numtop-2;
numstack[numtop++]=temp;
}
else if(charstack[chartop-1]=='/')
{
temp=x/y;
numtop=numtop-2;
numstack[numtop++]=temp;
}
chartop--;
}
}
}
int main()
{
scanf("%s", equation);
printf("%s\n", equation);
convert();
printf("%d\n", numstack[numtop-1]);
return 0;
}