#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int stack[500];
int top = 0;

void push(int num){
	stack[top] = num;
	++top;
}

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

int main(){
	int num;
	int tmp1, tmp2;
	char line[10];

	while(scanf("%s", line) != EOF){
		if(strcmp(line, "fin") == 0)
			break;
		if(strcmp(line, "+") == 0){
			tmp1 = pop();
			tmp2 = pop();

			push(tmp1 + tmp2);
		}else if(strcmp(line, "*") == 0){
			tmp1 = pop();
			tmp2 = pop();
			push(tmp1 * tmp2);
		}else if(strcmp(line, "-") == 0){
			tmp1 = pop();
			tmp2 = pop();
			push(tmp2 - tmp1);
		}else{
			push(atoi(line));
		}
	}
	printf("%d\n", pop());
	return 0;
}
