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

int getValue(char * InputBuff, int * InputPoint);

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

/* suuti hennkan */
int getValue(char * InputBuff, int * InputPoint)
{
	char ToAtoi[7];
	int  ValueDigits;
	
	ValueDigits=0;
	while(isdigit(InputBuff[(*InputPoint)]) != 0)
	{
		ToAtoi[ValueDigits] = InputBuff[(*InputPoint)];
		ValueDigits++;
		(*InputPoint)++;
	}
	ToAtoi[ValueDigits] = '\0';
	
	return atoi(ToAtoi);
}