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

int top,a[1000];
int pop(void);
void push(int);

int main()
{
  int x,y;
  char str[100];
  top = 0;

  while(scanf("%s", str) !=EOF )
    {
      if(str[0]=='+')
	{
	  x = pop();
	  y = pop();
	  push(x+y);
	}
      else if(str[0]=='-')
	{
	  x = pop();
	  y = pop();
	  push(y-x);
	}
      else if(str[0]=='*')
	{
	  x = pop();
	  y = pop();
	  push(x*y);
	}
      else
	{
	  x = atoi(str);
	  push(x);
	}
    }
  printf("%d\n",pop());
  return 0;
}
void push(int n)
{
  top = top+1;
  a[top]=n;
}
int pop()
{
  top = top-1;
  return a[top+1];
}

  

