#include <stdio.h>
#include <stdlib.h>
 
#define MAX 100
 
int pop();
void push(int);
 
int stack[MAX];
int top = 0;
 
int main(){
 
  int a, b, d;
  char c[7];
 
  while((scanf("%s", &c))!= EOF){
 
    if(c[0] == '+' || c[0] == '-' || c[0] == '*'){
 
      switch(c[0]){
 
      case '+':
       
    a = pop();
       
    b = pop();
       
    push(a + b);
       
    break;
 
 
      case '-':
       
    a = pop();
       
    b = pop();
 
    push(b - a);
 
    break;
 
 
      case '*':
      
    a = pop();
       
    b = pop();
 
    push(a * b);
 
    break;
 
 
      default:
 
    break;
     
      }
    }
 
    else{
 
      d = atoi(c);
 
      push(d);
 
    }
 
  }
 
  printf("%d\n", pop());
   
  return 0;
 
}
 
int pop(){
 
  if(top <= 0)
    return 0;
  else
    top = top - 1;
 
 
  return stack[top + 1];
  
}
 
void push(int data){
 
  top++;
   
  stack[top] = data;
   
}