#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];
	int stackp=0, p=0;
	scanf("%s",&code);
	while (code[p]!='\0') {
		if (code[p]=='+'||code[p]=='-'||code[p]=='*') {
			int a, b;
			a=pop_(); stackp--;
			b=pop_(); stackp--;
			switch (code[p]) {
				case '+':
				    push_(a+b);
				    stackp--;
				    break;
				case '-':
				    push_(b-a);
				    stackp--;
				    break;
				case '*':
				    push_(a*b);
				    stackp--;
				    break;
				default:
				    break;
			}
		} else push_(code[p]-'0');
		p++;
	}
	printf("%d",pop_());
	return 0;
}