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

int main(){
	int x[100], i = 0;
	char s[100];

	while( scanf("%s", s) != EOF){
		if(s[0] == '+'){
			x[i-2] += x[i-1];
			i--;
		}else if(s[0] == '-'){
			x[i-2] -= x[i-1];
			i--;

		}else if(s[0] == '*'){
			x[i-2] *= x[i-1];
			i--;
		}else{
			x[i++] = atoi(s);
		}
	}

	printf("%d\n", x[0]);
	return 0;
}