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

int s[1000],top;
int pop();
void push(int);

int main(){
  int l,m;
  char h[100];
  top=0;

  while(scanf("%s", h) !=EOF){
    if(h[0] == '-')
      {

	m=pop();
	l=pop();
	push(l-m);

      }
    else if(h[0] == '+')
      {

	m=pop();
	l=pop();
	push(l+m);
      }
    else if(h[0] == '*')
      {
	l=pop();
	m=pop();
	push(l*m);
      }
    else push(atoi(h));
    }
  
  printf("%d\n",pop());

  return 0;
}


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

void push(int d){
  s[++top]=d;
}
       

