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

void push(int x);
int pop();

int S[100];
int top = 0;

int main(void) {
	char s[100];
	while(scanf("%s",s) != EOF){
		int a = 0,b = 0;
		switch(s[0]){
			case '+':
			a = pop();
			b = pop();
			push(a+b);
			break;
			case '-':
			a = pop();
			b = pop();
			push(b-a);
			break;
			case '*':
			a = pop();
			b = pop();
			push(a*b);
			break;
			default:
			push(atoi(s));
		}
	}
	printf("%d\n",S[1]);
	return 0;
}

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

int pop(){
	top--;
	return S[top+1];
}
