#include<stdio.h>
#include<stdlib.h>
int main(){
  int i=0,T[100];
  char S[100];
  while (scanf("%s", S) != EOF){
    if(S[0] == '+') {T[i-2] = T[i-2] + T[i-1]; i--;}
    else if (S[0] == '-') {T[i-2] = T[i-2] - T[i-1]; i--;}
    else if (S[0] == '*') {T[i-2] = T[i-2] * T[i-1]; i--;}
    else {T[i] = atoi(S);i++;}
} 



  printf("%d\n",T[0]);

return 0;
}