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

int getValue(char TopCh);

int main(void)
{
	int  Stack[200];  /* operand(100) + operator(99) */
	int  StackPoint;
	int  Value;
	char ch;
	
	StackPoint = 0;
	while(scanf("%c", &ch) != EOF)
	{
		if(ch == '-') /* minus */
		{
			scanf("%c", &ch);
			if(isspace(ch) != 0) /* operator */
			{
				Value = Stack[StackPoint-2] - Stack[StackPoint-1]; /* Caluculation */
				Stack[StackPoint-2] = Value;
				StackPoint--;
			}
			else /* minus sign */ 
			{
				Value = getValue(ch);
				Stack[StackPoint] = -1 * Value;
				StackPoint++;
			}
		}
		else if(ch == '+') /* plus */
		{
			Value = Stack[StackPoint-2] + Stack[StackPoint-1]; /* Caluculation */
			Stack[StackPoint-2] = Value;
			StackPoint--;
		}
		else if(ch == '*') /* multiply */
		{
			Value = Stack[StackPoint-2] * Stack[StackPoint-1]; /* Caluculation */
			Stack[StackPoint-2] = Value;
			StackPoint--;
		}
		else if(isdigit((unsigned char)ch) != 0)	/* judge operand */
		{
			Value = getValue(ch);
			Stack[StackPoint] = Value;
			StackPoint++;
		}
		else	/* Space or Bad Charactor*/
		{
		}
		
	}
	
	printf("%d\n", Stack[0]);
	
	return 0;
}

/* suuti hennkan */
int getValue(char TopCh)
{
	char ToAtoi[7];
	int  ValueDigits;
	char ch;
	
	ToAtoi[0] = TopCh;
	ValueDigits=1;
	scanf("%c", &ch);
	while(isdigit(ch) != 0)
	{
		ToAtoi[ValueDigits] = ch;
		ValueDigits++;
		scanf("%c", &ch);
	}
	ToAtoi[ValueDigits] = '\0';
	
	return atoi(ToAtoi);
}