#include <stdio.h>
#include <stdlib.h>
#define N 101
#define X 1000000
int main(){
  int i=0,top=1,num1=0,r;
  char s[X];
  long array[N];
  while( scanf("%s",s) !=  EOF){
    
    if(s[0]!='+' && s[0]!='-' && s[0]!='*') {
      num1=atoi(s);
      i++;
      array[i]=num1;
      continue;
    }
    
    if(s[0]=='+')      {num1=array[i-1]+array[i]; top=i-1; array[i-1]=num1; i=top;}
    else if(s[0]=='-') {num1=array[i-1]-array[i]; top=i-1; array[i-1]=num1; i=top;}
    else if(s[0]=='*') {num1=array[i-1]*array[i]; top=i-1; array[i-1]=num1; i=top;}
      
  }

  printf("%ld\n",array[i]);

  return 0;
}
