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


int initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

#define false 0
#define true 1
#define MAX 199

int top=0;
int S[MAX];

int main(){
  int x,y,pl,mi,ka;
  char s[MAX];
 
  while( scanf("%s",s) != EOF ){
    
    if ( s[0] == '+' ){
      pl = pop() + pop();          
      push(pl);     
    }
    
    else if ( s[0] == '-' ){
      x = pop();
      y = pop(); 
      mi= y-x;            
      push(mi);     
    }
    
    else if ( s[0] == '*' ){
      ka =  pop() * pop();    
      push(ka);
    }
    
    else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());
  
  return 0;
}

int initialize(void){
  return top=0;
}

int isEmpty(void){
  if(top==0) return true;
  else return false;
}

int isFull(void){
  if(top >= MAX - 1) return true;
  else return false;
}

void push(x){
  if(isFull() == true) exit(1);
  top++;
  S[top] = x;
}

int pop(void){
  if(isEmpty() == true) exit(1);
  top--;
  return S[top+1];
}
  
  

