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

int main(void){
	
	int stack[100] = {0};
	int top = 0;
	char input, dump;
	
	for(;;){
		scanf("%c", &input);
		if( input == '\n' ) break;
		else if( input >= '0' && input <= '9' ) stack[top] = (stack[top]*10+input-'0');
		else if( input == ' ' ) {
			if( stack[top] != 0 ) top++;
		}
		else {
			if( input == '+' ) stack[top-2] += stack[top-1];
			else if( input == '-' ) stack[top-2] -= stack[top-1];
			else if( input == '*' ) stack[top-2] *= stack[top-1];
			else stack[top-2] /= stack[top-1];
			top--;
			stack[top] = 0;
		}
	}
	
	printf("%d\n", stack[0]);
	
}
