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

int main() {

	int counter = 0;
	char s[100];
	
	int stack[100];
	

	while( scanf("%s", s) != EOF ) {
		if ( s[0] == '+' ) {
			stack[counter - 2] = stack[counter - 2] + stack[counter - 1];
			counter--;
		} else if ( s[0] == '-' ) {
			stack[counter - 2] = stack[counter - 2] - stack[counter - 1];
			counter--;
		} else if ( s[0] == '*' ) {
			stack[counter - 2] = stack[counter - 2] * stack[counter - 1];
			counter--;
		} else {
			stack[counter] = atoi(s);
			counter++;
		}
	}
	printf("%d\n",stack[0]);
	return 0;
}
