#include <stdio.h>

int main() {
	char ch[(10^6)];
	long int stack[(10^9)], stackp=0;
	while (scanf("%s",&ch)!=EOF) {
		if (ch[0]=='+') {
			stackp--;
			stack[stackp-1]=stack[stackp-1]+stack[stackp];
		} else if (ch[0]=='-') {
			stackp--;
			stack[stackp-1]=stack[stackp-1]-stack[stackp];
		} else if (ch[0]=='*') {
			stackp--;
			stack[stackp-1]=stack[stackp-1]*stack[stackp];
		} else {
			stack[stackp]=atoi(ch);
			stackp++;
		}
	}
	return 0;
}