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

#define N 200
#define M 20000

int main()
{
  int top = 1,S[N],y;
  char str[M];
  
 while(scanf("%s ",str) != EOF){
   
   
    if(str[0] >= '0' && str[0] <= '9'){
      S[top] = atoi(str);
    }
    else if(str[0] == '+'){
      y = S[top-2] + S[top-1];
    top -= 2;
    S[top] = y;
  }
  else if(str[0] == '-'){
    y = S[top-2] - S[top-1];
    top -= 2;
     S[top] = y;     
  }
  else{
    y = S[top-2] * S[top-1];
    top -= 2;
    S[top] = y;
  }

  top++;
  }

  top--;
  printf("%d\n",S[top]);

  return 0;
}
	

 


  

  
	     

  

