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

#define N 200
#define C 10000

int main(){

  int i;
  int count = 0, n = 0;
  char in[N][C];
  int ans[N];
  int out = 0;

  i = 0;
  while(scanf("%s", in[i]) != EOF){
    
    count++;
    i++;
  }
  
  for(i = 0; i < count; i++){
    
    
    
    if(in[i][0] == '+'){
      
      if(in[i - 1][0] == '+' ||  in[i - 1][0] == '-' || in[i - 1][0] == '*'){
	
	ans[n - 2] = ans[n - 1] + ans[n - 2];
	n -= 1;
	
      }
      else if(in[i - 2][0] == '+' ||  in[i - 2][0] == '-' || in[i - 2][0] == '*'){
	
	ans[n - 1] = ans[n - 1] + atoi(in[i - 1]);
	
      }
      else {
	
	ans[n] = atoi(in[i - 2]) + atoi(in[i - 1]);
	n++;
	
      }
      
    }
    
    else if(in[i][0] == '-'){
      if(in[i - 1][0] == '+' ||  in[i - 1][0] == '-' || in[i - 1][0] == '*'){
	
	ans[n - 2] = ans[n - 1] - ans[n - 2];
	n -= 1;
	
      }
      else if(in[i - 2][0] == '+' ||  in[i - 2][0] == '-' || in[i - 2][0] == '*'){
	
	ans[n - 1] = ans[n - 1] - atoi(in[i - 1]);
	
      }
      else {
	
	ans[n] = atoi(in[i - 2]) - atoi(in[i - 1]);
	n++;
	
      }
      
    }
    
    else if(in[i][0] == '*'){
      if(in[i - 1][0] == '+' ||  in[i - 1][0] == '-' || in[i - 1][0] == '*'){
	
	ans[n - 2] = ans[n - 1] * ans[n - 2];
	n -= 1;
	
      }
      else if(in[i - 2][0] == '+' ||  in[i - 2][0] == '-' || in[i - 2][0] == '*'){
	
	ans[n - 1] = ans[n - 1] * atoi(in[i - 1]);
	
      }
      else {
	
	ans[n] = atoi(in[i - 2]) * atoi(in[i - 1]);
	n++;
	
      }
     
    }
    
    if(in[i][0] != '+' &&  in[i][0] != '-' && in[i][0] != '*' && in[i + 1][0] != '+' &&  in[i + 1][0] != '-' && in[i + 1][0] != '*' && in[i + 2][0] != '+' &&  in[i + 2][0] != '-' && in[i + 2][0] != '*'){
      ans[n] = atoi(in[i]);
      n++;
    }

  }
  
  printf("%d\n", ans[0]);
  
  return 0;
}