#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 101
void initialize(void);
void push(int);
int pop(void);
int isEmpty(void);
int isFull(void);
int S[MAX];
int top;
 
int main(void){
 
 
  int x,y,i=0;
  char s[MAX];
  initialize();
  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      x = pop();
      y = pop();
      x = x + y;
    }
    else if(s[0] == '-'){
      x = pop();
      y = pop();
      x = y - x;
    }
    else if(s[0] == '*'){
      x = pop();
      y = pop();
      x = x * y;
    }
    else x = atoi(s);
 
    push(x);
  }
 
 
  printf("%d\n",S[top]);
  return 0;
}
 
void initialize(void){
  top = 0;
}
 
int isEmpty(void){
  if( top == 0)return 1;
  else return 0;
}
 
int isFull(void){
  if( top >= MAX -1)return 1;
  else return 0;
}
 
void push(int x){
  if(isFull() == 1) printf("error overflow\n");
 
  top++;
  S[top] = x;
}
 
int pop(){
  if(isEmpty() == 1) printf("error underflow\n");
 
  top--;
  return S[top+1];
}