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

#define		OPERAND			100+100+10
#define		OPERATOR		100+100+10		// +, -, *

int		pop(void);
void	push(int);

char		str[OPERAND+OPERATOR]={'\0'};
int			stack[OPERAND+OPERATOR]={0};

int		SUFX=0;

int		main(void)
{
	char		*p;
	int			x, y;
	int			rst;

	// 1???????????? ??°???????????????????????????
	fgets(str, sizeof(str), stdin);
	p = strtok( str, " " );

	// ?????????????????????????????°???
	push(atoi(p));
	//printf("p=%d\n",atoi(p));

	while(1)
	{
		p = strtok( NULL, " " );
		if( p == NULL )
		{
			break;
		}

		// ??????????????´???
		if(( *p=='+') || ( *p=='-') || ( *p=='*'))
		{
			y=pop();
			x=pop();
			if( *p=='+')
			{
				push(x+y);
				//printf("x+y=%d\n",x+y);
			}
			else if( *p=='-')
			{
				push(x-y);
			}
			else if( *p=='*')
			{
				push(x*y);
			}
		}
		else
		{
			// ??°???
			//printf("p=%d\n",atoi(p));
			push(atoi(p));
		}
	}
	rst = pop();
	printf("%d\n",rst);
	return 0;
}

void	push(int num)
{
	stack[SUFX] = num;
	SUFX+=1;
	return;
}

int		pop(void)
{
	SUFX-=1;
	return( stack[SUFX]);
}