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

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

int s[100],i=0;
int main()
{
  int x,y;
  char c[100];
  while(scanf("%c",c) != EOF)
    {
      if(c[0] == '+')
	{
	  x = pop();
	  y = pop();
	  push(x+y);
	}
      else if(c[0] == '-')
	{
	  x = pop();
	  y = pop();
	  push(y-x);
	}
      else if(c[0] == '*')
	{
	  x = pop();
	  y = pop();
	  push(x*y); 
	}
      else
	{
	  push(atoi(c));
	}
    }
  printf("%d\n",pop());

  return 0;
}

void push( int x )
{
  s[++i] = x;
}

int pop()
{
  i--;
  return s[i+1];
}

