#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
  int top=0,s[100];
  char str[100];

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

	printf("%d\n",s[top-1]);
	
  return 0;
}


