#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int Pop(void);
void Push(int);

int prin = 0;
int stack[100];

int main()
{

int i,j,x;
char s[100];

while(1){
if(scanf("%s",s) == EOF)
break;

if(s[0] == '+')
i = Pop();
j = Pop();
Push(j + i);
}
else if(s[0] == '-')
{
i = Pop();
j = Pop();
Push(j - i);
}
else if(s[0] == '*')
{
i = Pop();
j = Pop();
Push(j * i);
}
else{
x = atoi(s);
Push(x);
}
}
printf("%d\n",stack[prin];
return 0;
}

int Pop(void)
{
prin --;
return stack[prin + 1];
}

void Push(int x)
{
stack[++ prin] = x;
}