#include<stdio.h>
#include<string.h>
#include <stdlib.h>
int main(){
  int i,stack[100],n=0,m=-1;
  char enz[1000][1000];
  while(scanf(" %s ",enz[n]) != EOF) n++ ;
  for(i=0;i<n;i++){
    if(enz[i][0] >= '0' && enz[i][0]<= '9'){
      m++;
      stack[m]=atoi(enz[i]);
    }else if(enz[i][0] == '+'){
      m--;
      stack[m]=stack[m]+stack[m+1];
    }else if(enz[i][0] == '-'){
      m--;
      stack[m]=stack[m]-stack[m+1];
    }else if(enz[i][0] == '*'){
      m--;
      stack[m]=stack[m]*stack[m+1];
    }
 //   printf("%d m=%d str = %s\n",stack[m],m,enz[i]);
  }
  printf("%d\n",stack[m]);
  

}
