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

int main(){
  int i, j, num, top = 0;
  char s[200][6];
  int a[100];
  
  for(i = 0;(scanf("%s", s[i])) != EOF;i++)
    {
      if(s[i][0] == '+')
	{
	  top--;
	  a[top-1] = a[top-1] + a[top];
	}
      else if(s[i][0] == '-')
	{
	  top--;
	  a[top-1] = a[top-1] - a[top];
	}
      else if(s[i][0] == '*')
	{
	  top--;
	  a[top-1] = a[top-1] * a[top];
	}
      else
	{
	  a[top] = atoi(s[i]);
	  top++;
	}
    }
  printf("%d\n", a[top-1]);
      
  return 0;
}


