#include<stdio.h>
#include<stdlib.h>
#define MAX 100
int main(void){
  int num=0,stack_m[MAX];
  char stack[MAX];
  while(scanf("%s",stack)!=EOF){
    switch(stack[0]){
    case '+':
      stack_m[num-2]=stack_m[num-2]+stack_m[num-1];
      num--;
      break;
    case '-':
      stack_m[num-2]=stack_m[num-2]-stack_m[num-1];
      num--;
      break;
    case '*':
      stack_m[num-2]=stack_m[num-2]*stack_m[num-1];
      num--;
      break;
    default:
      stack_m[num] = atoi(stack);
      num++;
      break;
    }
  }
  printf("%d\n",stack_m[0]);
  return 0;
}