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


void push(int);
void pop(int);
int ans[100],point = 0;


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

  while( scanf("%s", s) != EOF ){

    if ( s[0] == '+' ){
      pop(1);
    } 
    
    else if ( s[0] == '-' ){  
      pop(2);
    } 

    else if ( s[0] == '*' ){
      pop(3);      
    } 
    
    else {

      push(atoi(s));
     

    }


  }

  
  printf("%d\n",ans[point - 1]);


  return 0;
}




void push(int mu){

  ans[point] = mu;
  point++;

}

void pop(enzan){

  if(enzan == 1){
    ans[point - 2] = ans[point - 1] + ans[point - 2];
    point--;      
      }
  else if(enzan == 2){
    ans[point - 2] = ans[point - 2] - ans[point - 1];
    point--;
  }
  else {
    ans[point - 2] = ans[point - 2] * ans[point - 1];
    point--;
  }

}