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

#define PLUS 0
#define MINUS -1
#define MUL -2
#define DIV -3

int main(){
	int formula[200];
	int stack[200];
	int sp = 0;
	int cnt = 0;
	char inputs[6];

	//input data
	while(scanf("%s", inputs) != EOF){
		//printf("%s\n", inputs);
		//printf("%c\n", inputs[0]);
		if(inputs[0] == '+'){
			formula[cnt] = PLUS;
		}else if(inputs[0] == '-'){
			formula[cnt] = MINUS;
		}else if(inputs[0] == '*'){
			formula[cnt] = MUL;
		}else if(inputs[0] == '/'){
			formula[cnt] = DIV;
		}else{
			formula[cnt] = atoi(inputs);
		}
		//printf("inputs: %d\n", formula[cnt]);
		cnt++;
	}

/*
	printf("formula: ");
	for(int i = 0; i < cnt; i++){
		printf("%d, ", formula[i]);
	}
	printf("\n");
*/
	
	//acc
	for(int i = 0;i < cnt;i++){
		if(formula[i] == PLUS){
			sp--;
			stack[sp - 1] += stack[sp];
		}else if(formula[i] == MINUS){
			sp--;
			stack[sp - 1] -= stack[sp];
		}else if(formula[i] == MUL){
			sp--;
			stack[sp - 1] *= stack[sp];
		}else if(formula[i] == DIV){
			sp--;
			stack[sp - 1] /= stack[sp];
		}else{
			stack[sp] = formula[i];
			sp++;
		}
/*
		printf("stack: ");
		for(int j = 0; j < sp; j++){
			printf("%d, ", stack[j]);
		}
		printf("\n");
*/
	}

	printf("%d\n", stack[sp - 1]);


}
