#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100

int main(void){
  int i=0, ans, y;
  int num[N];
  char s[N];
  
  while(scanf("%s",s) != EOF){
    
    switch(s[0]){
      
    case '+':

     num[i-2] = num[i-2] + num[i-1];
     //num[i-2] = ans;
      i--;
      
    case '-':
      num[i-2] = num[i-2] - num[i-1];
      //num[i-2] = ans;
      i--;
      
    case '*':
      num[i-2] = num[i-2] * num[i-1];
      //num[i-2] = ans;
      i--;
      
    default:
      y = atoi(s);
      num[i] = y;
     
    }
 i++; 
  }
  //printf("%s\n",s);
  printf("%d\n", num[0]);
  return 0;
}
     
	 