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

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

int stack[1000];
int stack_size = 0;

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

void push(int p){
  stack[stack_size++] = p;
}

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


