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

void push(int);

int pop(void);

int top,t[101];

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

