#include <stdio.h>
#include <stdlib.h>
void Push(int *,int ,int *);
int Pop(int *,int *);
int main()
{
int S[100];
int i;
int ans;
char *a;
int s1,s2;
int s_top =0;
for(i=0;i<100;i++)
{
scanf("%s",a);
if(atoi(a) != 0 ) Push(S,atoi(a), &s_top);
else 
{
s2=Pop(S,&s_top);
s1=Pop(S,&s_top);

if (a== '+' )ans=s1 +s2;
else if (a== '-' )ans=s1 - s2;
else if (a== '*' )ans= s1* s2;
else if (a== '/' )ans= s1 /  s2;
Push (S,ans,&s_top);
}
}

printf("%d\n",Pop(S,&s_top));
return 0;
}

void Push (int *S,int a,int *s_top)
{
s_top++;
S[*s_top] = a;
}

int Pop (int *S, int *s_top)
{
s_top--;
return S[*s_top+1];
}