#include <stdio.h>

int main(void)
{
	int x[3], top = -1;
	char ch;

	while (1) {
		ch = getchar();

		if (ch == '+') {
			x[top - 1] = x[top - 1] + x[top];
			top--;
		}
		else if (ch == '-') {
			x[top - 1] = x[top - 1] - x[top];
			top--;
		}
		else if (ch == '*') {
			x[top - 1] = x[top - 1] * x[top];
			top--;
		}
		else if (ch <= '9'&&ch >= '0') {
			x[top + 1] = ch - '0';
			top++;
		}
		else if (ch == '\n') break;
	}

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

	return 0;
}