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


int main(){
  char calc[6];
  int stack[100];
  int top=0;
  while(scanf("%s",calc)!=EOF){
    switch(calc[0]){
    case '+':
      stack[top-1]+=stack[top];
      --top;
      break;
  
    case '-':
      stack[top-1]-=stack[top];
      --top;
      break;

    case '*':
      stack[top-1]*=stack[top];
      --top;
      break;
      
    default:
      top++;
      stack[top]=atoi(calc);

    }
  }
    printf("%d\n",stack[1]);
      return 0;
}