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

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

int prin = 0;

int stack[1000];

int main()
{
 
  int i,j;
  char s[100];
  
  while(scanf("%s",s) != EOF){
   
     
    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
      {
	Push(atoi(s));
      }
  }
  printf("%d\n",Pop());
  return 0;
}
 
int Pop(void)
{
  prin --; 
  return stack[prin + 1];
}

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