#include <stdio.h>
#include <stdlib.h>

int num[100];
int t;

void push(int x) {
	num[++t] = x;
}

int pop() {
	return num[t--];
}

int main(void) {
	char formula[200];
	int a, b, c;
	
	t = 0;
	
	while ( scanf("%s", formula) != EOF ) {
		if (formula[0] == '+') {
			a = pop();
			b = pop();
			push( a + b );
		}else if (formula[0] == '-') {
			b = pop();
			a = pop();
			push( a - b );
		}else if (formula[0] == '*') {
			a = pop();
			b = pop();
			push( a * b );
		}else {
			c = atoi(formula);
			push(c);
		}
	}
	
	printf("%d\n", pop());

	return 0;
}