
#include <stdio.h>



int main(){

	int x,y;
	char str[33];
	int stack[100], pt_stack=0;

	

	while( scanf( "%s", str) != EOF ){

		if( str[0] == '+' ){
			x = stack[--pt_stack];
			y = stack[--pt_stack];
			stack[pt_stack] = x + y;
		}else if( str[0] == '-' ){
			x = stack[--pt_stack];
			y = stack[--pt_stack];
			stack[pt_stack] = x - y;
		}else if( str[0] == '*' ){
			x = stack[--pt_stack];
			y = stack[--pt_stack];
			stack[pt_stack] = x * y;
		}else{
			stack[pt_stack] = atoi(str);
			pt_stack++;
		}
	}

	printf( "%d\n", stack[0] );

	return 0;

}