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

#define MAX 101

void Initialize(int *);
int IsEmpty(int);
int IsFull(int);
void Push(int [],int,int *);
int Pop(int [],int *);

int main(){
  int top,x;
  int result,temp_a,temp_b;
  int Stack[MAX];
  char s[100];

  Initialize(&top);
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      temp_a = Pop(Stack,&top);
      temp_b = Pop(Stack,&top);
      x = temp_b + temp_a;
      Push(Stack,x,&top);
    }
    
    else if ( s[0] == '-' ){
      temp_a = Pop(Stack,&top);
      temp_b = Pop(Stack,&top);
      x = temp_b - temp_a;
      Push(Stack,x,&top);
    }
    
    else if ( s[0] == '*' ){
      temp_a = Pop(Stack,&top);
      temp_b = Pop(Stack,&top);
      x = temp_b * temp_a;
      Push(Stack,x,&top);
    }
    
    else {
      x = atoi(s);
      Push(Stack,x,&top);
    }
    
  }

  result = Pop(Stack,&top);
  printf("%d\n",result);
  
  return 0;
}

void Initialize(int *top){
  int i;

  *top = 0;
}

int IsEmpty(int top){
  if (top == 0)
    return 1;

  return 0;
}

int IsFull(int top){
  if (top == MAX - 1)
    return 1;

  return 0;
}

void Push(int S[],int x,int *top){
  if (IsFull(*top)){
    fprintf(stderr,"Over flow\n");
    exit(0);
  }

  (*top)++;
  S[*top] = x;
}

int Pop(int S[],int *top){
  if (IsEmpty(*top)){
    fprintf(stderr,"Under flow\n");
    exit(1);
  }

  (*top)--;
  return S[*top + 1];
}

