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

int main()
{
  char b[N];
  int x,i,count=0,stack[N],cal1,cal2,result,change;
  while(scanf("%s",b)!=EOF)
    {
      if(b[i]=='+' || b[i]=='-' || b[i]=='*')
	{
	  //printf("stack %d %d",stack[count-1],stack[count-2]);
	  //printf("%d %c\n",count,b[i]);
	  count--;
	  cal2=stack[count];
	  count--;
	  cal1=stack[count];
	  //printf("%d %d\n",cal1,cal2);
	  switch(b[i])
	    {
	    case '+':
	      result=cal1+cal2;
	      break;
	    case '*':
	      result=cal1*cal2;
	      break;
	    default:
	      result=cal1-cal2;
	    }
	  stack[count]=result;
	  count++;
	}
      else
	{
	  change=atoi(&b[i]);
	  stack[count]=change;
	  //printf("stack %d",stack[count]);
	  count++;
	}      
    }
  printf("%d\n",stack[count-1]);
  return 0;
}

