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

int main()
{
  int n = 0;
  int operands[100];
  char s[100];

  while( scanf("%s", s) != EOF )
    {
      if ( s[0] == '+' ){
	n--;
	operands[n] = operands[n] + operands[n + 1];
      } 
      else if ( s[0] == '-' ){
	n--;
	operands[n] = operands[n] - operands[n + 1];
      } 
      else if ( s[0] == '*' ){
	n--;
	operands[n] = operands[n] * operands[n + 1];
      } 
      else {
	n++;
	operands[n] = atoi(s);
      }
    }
  printf("%d\n", operands[1]);
  
  return 0;
}