#include <stdio.h>
#include <stdlib.h>

int main()
{
  int cal[100],i=0,j=0,n=0,e=0,cal1=0,oki=0,cal2=0,cal3=0;
  char k[1000];

  //入力
   while(scanf("%s",k) !=EOF )
    {
      if('0'<=k[0] && k[0]<='9')
	{
	  cal[e]=atoi(k);
	  e++;
	}
	
      else if(k[0]=='*' || k[0]=='+' || k[0]=='-' || k[0]=='/')
	{
	  cal2=cal[e-2];
	  cal3=cal[e-1];
	  if (k[0]=='*') cal[e-2]=cal2 * cal3;
	  else if(k[0]=='+')cal[e-2]=cal2 + cal3;
	  else if(k[0]=='-')cal[e-2]=cal2 - cal3;
	  else if(k[0]=='/')cal[e-2]=cal2 / cal3;
	  e--;
	}
	 

    }

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

