#include <stdio.h>


int ope[101];
char com[100];
int top = 0;

void push(int x) {
	top++;
	ope[top] = x;   
}

int pop() {
	top--;
	return ope[top+1];
}
  
int main() {
	int num1,num2;
	while( scanf("%s",com) != EOF) {
		if( com[0] == '+') push( pop() + pop());
		else if( com[0] == '-'){
			num1 = pop();
			num2 = pop();
			push(num2 - num1);
		}else if( com[0] == '*') push( pop() * pop());
		else push(atoi(com));
	}
	printf("%d\n",pop());
	return 0;
}
