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

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

int s[100];
int t;

int main()
{
  int a,b,n;
  char C[100];
  t = 0;
  while(scanf("%s",C)!=EOF)
    {
      if(C[0]=='+')
	{
	  a = pop();
	  b = pop();
	  push(a+b);
	}
      else if(C[0] == '-')
	{
	  b = pop();
	  a = pop();
	  push(a-b);
	}
      else if(C[0] == '*')
	{
	  a = pop();
	  b = pop();
	  push(a*b);
	}
      else
	{
	  n = atoi(C);
	  push(n);
	}
    }
  printf("%d\n",pop());
  return 0;
}

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

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

