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


int main()
{
  int top=0;
  char S[N];
  int S1[N];
  
  while(1)
    {
      top++;
      if((scanf("%s",S))==EOF) break;
   
      if(S[0]=='+')
	{
	  S1[top-2]=S1[top-2]+S1[top-1];
	  top=top-2;		    
	}
      else if(S[0]=='-')
	{
	  S1[top-2]=S1[top-2]-S1[top-1];
	  top=top-2;
	}
      else if(S[0]=='*')
	{
	  S1[top-2]=S1[top-2]*S1[top-1];
	  top=top-2;
	}
	 
      else
	{
	  S1[top]=atoi(S);
	}
           
    }

   printf("%d\n",S1[top - 1]);



  return 0;
}

