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

void push(int);
int pop();

int top,B[1000];

int main ()
{
  int a1,a2,top;
  char A[100];

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

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

