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

main()
{
  int S[MAX], i=0, x, a;
  char input[MAX];

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

    }

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