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

int main(){
  int x;
  char s[100];
  int S[100];
  int top=1;
    
  while( scanf("%s", s) != EOF )
    {
      if ( s[0] == '+' )
	{
	  x = (S[top])+(S[top-1]);
	  top--;
	  S[top] = x;
	}
      else if ( s[0] == '-' )
	{
	  x = (S[top-1])-(S[top]);
	  top--;
	  S[top] = x;
	}
      else if ( s[0] == '*' )
	{
	  x = (S[top])*(S[top-1]);
	  top--;
	  S[top] = x; 
	}
      else
	{
	  x = atoi(s);
	  top++;
	  S[top]=x;
	}
    }
  printf("%d\n",S[top]);
  return 0;
}

