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



int top=0;
int a[100];

void push(int);
int pop(void);

int main()
{
  int tmp1,tmp2;
  char s[100];


  
  
  while(scanf("%s",s) != EOF)
    {
      if(s[0] == '+')
	{
	  tmp1 = pop();
	  tmp2 = pop();
	  
	  push(tmp1+tmp2);
	  // printf("%d",S[top]);

	}
      else if(s[0] =='-')
	{
	   tmp1 = pop();
	   tmp2 = pop();

	   push(tmp2-tmp1);
	  
	}
      else if(s[0] =='*')
	{
	  tmp1 = pop();
	  tmp2 = pop();

	  push(tmp1*tmp2);
	}
      else
	{


	  push(atoi(s));
	  //	  printf("%d",tmp1);
	}
      
    }
  printf("%d\n",pop());

  return 0;
}

void push(int num)
{
 top++;
  a[top] = num;
 
 
}

int pop()
{
 
  top--;
  return a[top+1];
}



