#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
int stack[1000];
int n = 0;
int pop(){
	n --;
	return stack[n+1];
}
void push(char m){
	stack[++ n] = m;
	return ;
}
int main(void){
	char ch, input[100];
	int i = 0, len, tem1, tem2;
	while(scanf("%s", input) != EOF){
			if(input[0] == '+'){
				tem2 = pop();
				tem1 = pop();
				push(tem1 + tem2);
			}
				
			else if(input[0] == '*'){
				tem2 = pop();
				tem1 = pop();
				push(tem1 * tem2);
			}
			else if(input[0] == '-'){
				tem2 = pop();
				tem1 = pop();
				push(tem1 - tem2);
			}
			else{
				push(atoi(input));
			}	
	}
	printf("%d\n", pop());
	return 0;
}
