#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
#define N 100
  
int main(){
  int a, stack[N], i = 0;
  char s[N];
    
  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      stack[i - 2] += stack[i - 1];
      i -= 1;
    }
 
    else if(s[0] == '-'){
      stack[i - 2] -= stack[i - 1]; 
      i--;
    }
 
    else if(s[0] == '*'){
      stack[i - 2] *= stack[i - 1]; 
      i--;
    }
 
    else{
      a = atoi(s); // push
      stack[i] = a;
      i++;
    }
  }
 
  printf("%d\n",stack[0]); 
 
  return 0;
}