#include <stdio.h>
#include <string.h>
#define push_(A) stack[stackp]=A;stackp++
#define pop_() stack[stackp-1]

int main() {
	char code[250];
	int stack[150], stackp=0, p=0;
	scanf("%[^\r\n]",code);
	while (code[p]!='\0') {
		if (p>200) break;
		else if (code[p]==' ') p++;
		if (code[p]=='+'||code[p]=='-'||code[p]=='*') {
			int a, b;
			a=pop_(); stackp--;
			b=pop_(); stackp--;
			if (code[p]=='+')      {push_(a+b);stackp--;}
			else if (code[p]=='-') {push_(b-a);stackp--;}
			else if (code[p]=='*') {push_(a*b);stackp--;}
		} else push_(code[p]-'0');
		p++;
	}
	printf("%d",pop_());
	return 0;
}