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

int main(void)
{
	int		stack[100]	= {};
	char	number[7]	= {};
	int		degit		= 0;
	int		p			= 0;
	int		stop_flag	= 0;
	char	input		= '\0';
	int		i			= 0;
	
	while ( 1 ) {
		scanf("%c", &input);
		switch ( input ) {
			case ' ':
				if ( number[0] != '\0' ) {
					p++;
					stack[p] = atoi(number);
					for ( i = 0 ; i < degit+1; i++ ) {
						number[i] = '\0';
					}
					degit = 0;
				}
				break;
			case '+':
				stack[p-1] = stack[p] + stack[p-1];
				p--;
				break;
			case '-':
				stack[p-1] = stack[p-1] - stack[p];
				p--;
				break;
			case '*':
				stack[p-1] = stack[p] * stack[p-1];
				p--;
				break;
			case '\n':
				stop_flag = 1;
				break;
			default:
				number[degit] = input;
				degit++;
				break;
		}
		
		if ( stop_flag == 1 ) {
			break;
		}
	}
	
	printf("%d\n", stack[p]);
	
	return 0;
}
