#include <stdio.h>

int stack[100];
int index = 0;

void push(int v) {
	stack[index++] = v;
}

int pop(void) {
	return stack[--index];
}

int main(void) {
	int c;
	int v;
	int f;
	
	v = 0;
	f = 0;
	while ((c = getchar()) != EOF) {
		switch (c) {
		case '+':
			v = pop();
			push(pop() + v);
			break;
		case '*':
			v = pop();
			push(pop() * v);
			break;
		case '-':
			v = pop();
			push(pop() - v);
			break;
		default:
			if (('0' <= c) && (c <= '9')) {
				if (!f) {
					f = 1;
					v = 0;
				}
				v = (v * 10) + (c - '0');
			} else if (f) {
				push(v);
				f = 0;
			}
			break;
		}
	}
	printf("%d\n", pop());
	
	return 0;
}