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

#define N 100

int main(){
  char str[5000];
  int stac[N];
  int top = 0, num1, num2, i, j;
  
  while(scanf("%s", str) != EOF){
    
    num1 = atoi(str);
    if(num1 != 0){
      top++;
      stac[top] = num1;
    }
    else{
      if(strcmp(str, "+") == 0){
	num2 = stac[top];
	top--;
	num1 = stac[top];
	num1 = num1+num2;
	stac[top] = num1;
      }
      if(strcmp(str, "-") == 0){
	num2 = stac[top];
	top--;
	num1 = stac[top];
	num1 = num1-num2;
	stac[top] = num1;
      }
      if(strcmp(str, "*") == 0){
	num2 = stac[top];
	top--;
	num1 = stac[top];
	num1 = num1*num2;
	stac[top] = num1;
      }
    }
    
  }
    printf("%d\n", stac[top]);
  
  return 0;
}

