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

int main(){
  int stack[101], s_top = 0, x, i;
  char n[100];

  while ( ( scanf("%s",n) ) != EOF){
    if(n[0] == '+'){
      s_top -= 1;
      x = stack[s_top];
      x += stack[s_top + 1];
    }
    else if(n[0] == '-'){
      s_top -= 1;
      x = stack[s_top];
      x -= stack[s_top + 1];
    }
    else if(n[0] == '*'){
      s_top -= 1;
      x = stack[s_top];
      x *= stack[s_top + 1];
    }
    else{
      x = atoi(n);
      s_top += 1;
    }
    stack[s_top] = x;
  }      
  
  printf("%d\n" ,stack[s_top]);
  
  return 0;
}