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

#define N 100

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

int top;
int A[N];

int main()
{
  char c[N];
  int x,y;

  while(scanf("%s",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",A[top]);
  
  return 0;
}


void push(int x)
{
  top++;
  A[top]=x;
}

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

