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

#define O 100
#define E 99
#define N 1000000

int main()
{
  int i=0,j=0,cnt = 0,a[O]={0},A[O]={0};
  char Data[O];
  
  while(scanf("%s",Data) != EOF)
    {
      if((a[i] = atoi(Data)) == 0)
	{
	  if(cnt == 1)
	    {
	      a[0] = A[j-2];
	      a[1] = A[j-1];
	      cnt = 0;
	    }
	  switch(Data[0])
	    {
	    case '+':
	      A[j] = a[0] + a[1];
	      break;
	      
	    case '-':
	      A[j] = a[0] - a[1];
	      break;
	      
	    case '*':
	      A[j] = a[0] * a[1];
	      break;
		  
	    default:
	      break;
	    }
	  
	  a[0] = 0;
	  a[1] = 0;
	  i = 0;
	  j++;
	  cnt++;
	}
      else
	{
	  i++;
	  if(cnt == 1) cnt = 0;
	}
    }

  printf("%d\n"A[j-1]);

  return 0;
}

