#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(){
  char s[100];
  int a, b, x;
  int i;

  while(scanf("%s", s) != EOF){
    
    if(s[0] == '+'){
      a = pop();
      b = pop();
      x = b + a;
      
      push(x);
    }

    else if(s[0] == '-'){
      a = pop();
      b = pop();
      x = b - a;

      push(x);      
    }

    else if(s[0] == '*'){
      a = pop();
      b = pop();
      x = b * a;
      
      push(x);
    }

    else {
      push(atoi(s));
    }
  }

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


void initialize(void){
  top = 0;
}

void push(int x){
  if(isFull() == 1){
    printf("error(1)\n");
    exit(1);
  }
  
  top++;
  
  S[top] = x;
}

int pop(void){
  if(isEmpty() == 1){
    printf("error(2)\n");
    exit(2);
  }
  
  top--;

  return S[top + 1];
}

int isEmpty(void){
  int sta = 0;

  if(top == 0) sta = 1;

  return sta;
}

int isFull(void){
  int sta = 0;

  if(top >= MAX - 1) sta = 1;

  return sta;
}


