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

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


int main(){
  int i,j,a,b;
  char S[100];
  top = 0;

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

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

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