#include <stdio.h>
#include <stdlib.h>
#define STSIZE 100


void push(int);
int pop(void);

int stack[STSIZE];
int top = 0;

int main(){
  int i=0,j=0,num,num2;
  char wd[1000000];
  while(scanf("%s",wd) != EOF){
    if(wd[0] == '+'){
      num=pop();
      num2=pop();
      push(num+num2);
    }
    else if(wd[0] == '-'){
      num=pop();
      num2=pop();
      push(num2-num);
    }
    else if(wd[0] == '*'){
    num=pop();
    num2=pop();
    push(num2*num);
    }
    else {
      num = atoi(wd);
      push(num);
    }
  }
  i++;
  
  printf("%d\n",pop());
  return 0;
}

void push(int num){
  stack[top] = num;
  top++;
}

int pop(void){
  top--;
  return stack[top];
}

