#include <stdio.h>

int main(){
	char s;
	char S[7];
	int n[200];
	int stack[100];
	
	int num = 0;
	int snum = 0;
	int i = 0,j,k;
	//Input operands and operators
	while(1){
		scanf("%c",&s);
		
		if(s == '\n')break;
		
		switch(s){
			case '+':
				n[num] = -1;
				num++;
				break;
				
			case '-':
				n[num] = -2;
				num++;
				break;
				
			case '*':
				n[num] = -3;
				num++;
				break;
				
			case ' ':
				if(i != 0){
					n[num] = atoi(S);
					num++;
					
					for(i = 0;i < 6;i++){
						S[i] = '\0';
					}
					
					i = 0;
				}
				break;
				
			default:
				S[i] = s;
				i++;
				break;
		}
	}
	
	//Do operation
	for(i = 0;i < num;i++){
		switch(n[i]){
			case -1:
				stack[snum-2] = stack[snum-2]+stack[snum-1];
				snum--;
				break;
			
			case -2:
				stack[snum-2] = stack[snum-2]-stack[snum-1];
				snum--;
				break;
				
			case -3:
				stack[snum-2] = stack[snum-2]*stack[snum-1];
				snum--;
				break;
			
			default:
				stack[snum] = n[i];
				snum++;
		}
	}
	
	//Display result
	printf("%d\n",stack[0]);
	
	return 0;
}