#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 101

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

int top=0;
int s[MAX]={};

int main(){
  int x,rslt;
  char s[100];
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      push(pop()+pop());
    } else if ( s[0] == '-' ){
      rslt = pop() - pop();
      push(rslt*(-1));
    } else if ( s[0] == '*' ){
      push(pop()*pop());
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",pop());
  return 0;
}


// initialize() to caii it initialize function for convenience sake

int isEmpty(){
return top == 0;
}

 int isFull(){
   return top >= MAX - 1;
	   }

void  push(int x){
  if (isFull()){
    printf("array is full\n");
    exit(1);
  }
  top++;
  s[top] = x;
}

int  pop(){
    if (isEmpty()){
      printf("array is empty\n");
    exit(2);
  }
   
  top--;
  return s[top+1];
  }

