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

int main()
{
  int stack[100], elem, elem1, elem2, top;
  char c[100];

  top = 0;

  while( scanf("%s", c) != EOF )
    {
     
      if( c[0] == '+' )
	{
	  elem1 = stack[top-1];
	  top--;
	  elem2 = stack[top-1];
	  top--;
	  stack[top] = elem1 + elem2;
	  top++;
	}
      
      else if( c[0] == '-' )
	{
	  elem1 = stack[top-1];
	  top--;
	  elem2 = stack[top-1];
	  top--;
	  stack[top] = elem2 - elem1;
	  top++;
	}

      else if( c[0] == '*' )
	{
	  elem1 = stack[top-1];
	  top--;
	  elem2 = stack[top-1];
	  top--;
	  stack[top] = elem1 * elem2;
	  top++;
	}
      
      else
	{
	  stack[top] = atoi( c );
	  top++;
	}
    }
  
  printf("%d\n", stack[0]);
  
  return 0;
}

