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

int s[1000];
int top;

void initialize(){
	top = 0;
}

int isEmpty(){
	return top == 0;
}

int isFull(){
	return top > 1000;
}

void push(int x){
	if(isFull()){
		exit(1);
	}
	top++;
	s[top] = x;
}

int pop(){
	if(isEmpty()){
		exit(0);	
	};
	top--;
	return s[top+1];
}

int main(void){
	int a,b,top=0;
	char str[10];
	while((scanf("%s",str)!=EOF)){
		if((strcmp(str,"+"))==0){
			a = pop();
			b = pop();
			push(b+a);
		}else if((strcmp(str,"-"))==0){
			a = pop();
			b = pop();
			push(b-a);
		}else if((strcmp(str,"*"))==0){
			a = pop();
			b = pop();
			push(b*a);
		}else{
			push(atoi(str));
		}
	}
	printf("%d\n",pop());
	return 0;
}
