#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void push(int a[],char c,int *top)
{
	switch(c)
	{
		case '+':a[*top-1]=a[*top-1]+a[*top];break;
		case '-':a[*top-1]=a[*top-1]-a[*top];break;
		case '*':a[*top-1]=a[*top-1]*a[*top];break;
	}	
	*top=*top-1;
}

int main(int argc, char *argv[])
{
	char a[1000],num[1000];
	int b[100];
	int i,top=-1,j=0;//j????¬???¬??¢?????°??? 
	while(scanf("%s",a)!=EOF)
	{
	for(i=0;i<strlen(a);i++)
	{
		if(strlen(a)!=1&&a[i]=='-')//?´???° 
		{
			num[j]='-';
			j++;
		}		
		else if(a[i]>='0'&&a[i]<='9')//?????????????????????????????\?????¨?????\
		{
			num[j]=a[i];
			j++;
			if(i+1==strlen(a))
			{
				top++;
				num[j]='\0';
				b[top]=atoi(num);
				j=0;
			}
		}
	 	else if(a[i]!=' ')
		{
			push(b,a[i],&top);//??°?????°??????????¬?????????¶ 
		}
		
	}
	}
	printf("%d\n",b[top]);
}