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

#define MAX_S 101
#define MAX_CH 100

int main(){

  int S[MAX_S];
  int top=0;
  char ch[6];
  int sum;

  while(scanf("%s",ch) != EOF){
    if(ch[0] == '+'){
      S[top-1] += S[top]; 
      top--;
    }
    else if(ch[0] == '-'){
      S[top-1] -= S[top]; 
      top--;
    }
    else if(ch[0] == '*'){
      S[top-1] *= S[top]; 
      top--;
    }
    else if(ch[0] == '*'){
      S[top-1] *= S[top]; 
      top--;
    }
    else{
      top++;
      S[top] = atoi(ch);
    }
  }

  printf("%d\n",S[1]);

  return 0;
}