#include <stdio.h>


int main()
{
	char c;
	int num;
	int stack[200];
	int sp;


	sp = 0;
	while((c = getchar()) != '\n'){
		if(isdigit(c)){
			ungetc(c, stdin);
			scanf("%d", &num);
			stack[sp++] = num;
		}else{
			switch(c){
				case '+':
					stack[sp - 2] = stack[sp - 2] + stack[sp - 1];
					sp--;
				break;
				case '-':
					stack[sp - 2] = stack[sp - 2] - stack[sp - 1];
					sp--;
				break;
				case '*':
					stack[sp - 2] = stack[sp - 2] * stack[sp - 1];
					sp--;
				break;
			}
		}
	}

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

	return 0;
}
