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

int top;
char C[100];

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

int main(){
  int i,a,b,x,q,n;
  char s[100];

 
  while(1){
      q = scanf("%s",s);
      if(q == EOF) break;
      if(s[0] == '+')
	{
	  a = pop();
	  b = pop();
	  push(a+b);
	}
      else if(s[0] == '-')
	{
	  a = pop();
	  b = pop();
	  push(b-a);
	}
      else if (s[0] == '*')
	{
	  a = pop();
	  b = pop();
	  push(a*b);
	}
      else
	{
	  x = atoi(s);
	  push(x);
	}
    
    }
  n = pop();
  printf("%d\n",n);
  
  return 0;
}

int pop()
{
  top--;
  return C[top+1];
}
void push(int x)
{
  top++;
  C[top] = x;
}