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

int main(){
  int x[100],i=0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){

      x[i-2] = x[i-2] + x[i-1];
      i = i-2;

    } 

    else if ( s[0] == '-' ){
      
      x[i-2] = x[i-2] - x[i-1];
      i = i-2;
  
    } 
    
    else if ( s[0] == '*' ){
    
      x[i-2] = x[i-2] * x[i-1];
      i = i-2;
      
    } 
    
    else {
    
      x[i] = atoi(s);
      
    }
    
    i++;
  }

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