#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#define N 1000
#define True 1
#define False 0

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

int top = 0;
int A[1000];

int main(){
  int a = 0, b = 0, x = 0;
  char s[100];
  
  while((scanf("%s",s)) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(s[0] == '-'){
      a = pop();
      b = pop();
      push(b - a);
    }
    else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }
    else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());
  
  return 0;
}
/*
int isEmpty(void){
  if(top == 0)return True;
  else return False;
}

int isFull(void){
  if(top >= N-1)return True;
  else return False;
}
*/
void push(int x){
  /*
  if((isFull()) == True){
    printf("Overflow!");
  }
  
  else {*/
    top++;
    A[top] = x;
    // }
  
}

int pop(void){
  /*
  if((isEmpty()) == True){
    printf("Underflow!");
  }
  
  else {*/
    top--;
    return A[top + 1];
    //}
}

