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

int main()
{
  int top = 0,sub;
  char s[100];
  int t[100];
  t[0] = 0;
  top++;
  while(scanf("%s",s)!= EOF)
    {
      if(s[0] == '\n')
	{
	  break;
	}
      if(s[0] == '+')
	{
	  sub = t[top -2] + t[top -1];
	 if(top == 0)
	    {
	      break;
	    }
	 top--;
	 if(top == 0)
	    {
	      break;
	    }
	 top--;
	  if(top >= 100)
	    {
	      break;
	    }
	  t[top] = sub;
	}
      else if(s[0] == '-')
	{
	  sub = t[top -2] - t[top -1];
	  if(top == 0)
	    {
	      break;
	    }
	  top--;
	  if(top == 0)
	    {
	      break;
	    }
	  top--;
	  //printf(" aa %d aa",top);
	  if(top >= 100)
	    {
	      break;
	    }
	  t[top] = sub;
	}
      else if(s[0] == '*')
	{
	  
	  sub = t[top -2] * t[top -1];
	  if(top == 0)
	    {
	      break;
	    }
	  top--;
	  if(top == 0)
	    {
	      break;
	    }
	  top--;
	  if(top >= 100)
	    {
	      break;
	    }
	  t[top] = sub;
	}
      else
	{
	  t[top] = atoi(s);
	}
      //printf(" %d test  %d ",top,t[top]);
      top++;
    }
  printf("%d\n",t[top - 1]);
  
  
  return 0;
}


