#include<stdio.h>
#include<stdlib.h>
int main(void)
{
	int stack[100],last=0;
	char s[100];
	while(scanf("%s",s)!=EOF)
	{
		switch(s[0]){
		case '+':
			stack[last-2]=stack[last-2]+stack[last-1];
			last--;
			break;
		case '-':
			stack[last-2]=stack[last-2]-stack[last-1];
			last--;
			break;
		case '*':
			stack[last-2]=stack[last-2]*stack[last-1];
			last--;
			break;
		default :
			stack[last]=atoi(s);
			last++;
			break;
		}
	}
	printf("%d\n",stack[last-1]);

	return 0;
}