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

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

int main(void) {
	int a,b;
	top = 0;
	char str[100];

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