#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 500
int main() {
  int i,result,count=0,num,j,len;
  int stack[99];
  char n[MAX];
  
  fgets(n,MAX,stdin);
  len = strlen(n);
  for(i=0;i<len;i++)
    {
      if(n[i]>=48 && n[i]<=57 && n[i+1]==' ')
	{
	  stack[count] = atoi(&n[i]);
	  count++;
	}
      else if(n[i]>=48 && n[i]<=57 && n[i+1]!=' ')
	{
	  stack[count] = atoi(&n[i]);
	  num = stack[count];
	  while(num!=0)
	    {
	      num /= 10;
	      i++;
	    }
	  count++;
	}
      /*for(j=0;j<count;j++)
	{
	  printf("%d ",stack[j]);
	
	}
	printf("\n");*/
      if(n[i]==43)
	{
	  stack[count-2]+=stack[count-1];
	  count--;
	}
      if(n[i]==45)
	{
	  stack[count-2]-=stack[count-1];
	  count--;
	}
      if(n[i]==42)
	{
	  stack[count-2]*=stack[count-1];
	  count--;
	}
    }
  printf("%d\n",stack[count-1]);
}
      

