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

int calDigNum(char*, int, int);
int main(void){
	char c[400], tmp[7];
	int i = 0, j = 0, dig_num = 1, stack[199], last;
	
	fgets(c, 399, stdin);
	while(c[i] != '\0'){
		if(isdigit(c[i])){
			dig_num = calDigNum(c, i+1, 1);
			strncpy(tmp, c+i, dig_num);
			tmp[dig_num] = '\0';
			i += dig_num-1;
			
			stack[j] = (int)strtol(tmp, NULL, 10);
			j++;
		}else{
			switch(c[i]){
				case '+':
				stack[j-2] += stack[j-1];
				break;
				case '-':
				stack[j-2] -= stack[j-1];
				break;
				case '*':
				stack[j-2] *= stack[j-1];
				break;
			}
			j--;
		}
		i += 2;
	}
	printf("%d\n", stack[0]);
	return 0;
}

int calDigNum(char* c, int i, int dig_num){
	if(isdigit(c[i])){
		return calDigNum(c, i+1, dig_num+1);
	}else{
		return dig_num;
	}
}
