#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Push(int *,int ,int *);
int Pop(int *,int *);
int main()
{
int S[100];
int i;
int ans,z;
char a[100];
int s1,s2;
int s_top =0;
for(i=0;i<100;i++)
{
z=scanf("%s",a);
if(z==EOF) break;
//if(atoi(a) != 0 ) Push(S,atoi(a), &s_top);
//else
//{
//s2=Pop(S,&s_top);
//s1=Pop(S,&s_top);
if (a== '+' )ans= Pop(S,&s_top)+Pop(S,&s_top);
else if (a== '-' )ans=Pop(S,&s_top) - Pop(S,&s_top);
else if (a== '*' )ans= Pop(S,&s_top)* Pop(S,&s_top);
else if (a== '/' )ans= Pop(S,&s_top) /  Pop(S,&s_top);
else ans=atoi(a)
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];
}