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

#define N 100
 
int main(){
  int a, stack[N], i = 0;
  char s[N];
   
  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      stack[i - 2] += stack[i - 1]; //push = pop + pop
      i -= 1;
    }

    else if(s[0] == '-'){
      stack[i - 2] -= stack[i - 1]; //push = pop - pop
      i--;
    }

    else if(s[0] == '*'){
      stack[i - 2] *= stack[i - 1]; // push = pop * pop
      i--;
    }

    else{
      a = atoi(s); // push
      stack[i] = a;
      i++;
    }
  }

  printf("%d\n",stack[0]); //result

  return 0;
}