#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define TRUE 1
#define FALSE 0
#define MAX 1000 

int top,S[MAX];
char s[MAX];

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

int main(){
  int a,b;
  
  while( scanf("%s",s) != EOF ){
    if ( s[0] == '+' ){
      b=pop();
      a=pop();
      push(a+b);      
    } else if ( s[0] == '-' ){
      b=pop();
      a=pop();
      push(a-b);      
    } else if ( s[0] == '*' ){ 
      b=pop();
      a=pop();
      push(a*b);	
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  
  return 0;
}
void initialize(void){
  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(int x){
  if(isFull()){
    fprintf(stderr,"Overflow!!\n");
    exit(8);
  }
  else{
    top++;
    S[top]=x;
  }
}
int pop(void){
  if(isEmpty()){
    fprintf(stderr,"Underflow!!\n");
    exit(8);
  }
  else{
    top--;  
    return S[top+1];
  }
}