#include<stdio.h>
#define N 100
#include<stdlib.h>


main(){
  
  int i,j,top=0,k;
  int t[N];
  char c[200];
  while(scanf("%s",&c)!=EOF){
    
    if(c[0]=='-'){
      t[top-1] = t[top] - t[top-1];
      top--;
    }
    else if(c[0]=='+'){
      t[top-1] = t[top] + t[top-1];
      top--;
    }
    else if(c[0]=='*'){
      t[top-1] = t[top] * t[top-1];
      top--;
    }
    else{
      top++;
      t[top]=atoi("c");
      
    }
    
  }
  printf("%d\n",t[top]);
  return 0;
  
}