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

#define MAX 100

void initialize();
void push(int x);
int pop();
int isEmpty();
int isFull();

int top=0;
int s[MAX];

int main()
{
  int x,y,z,i=0;

  char c[MAX];
	
	while(scanf("%s",c)!=EOF){

	  

		if(c[0]=='-')
		{
	      
		y=pop();
		x=pop();
		z=x-y;
		push(z);
		}
		
		else if(c[0]=='+')
		{
	     
		y=pop();
		x=pop();
	        
		z=x+y;
		push(z);
		}
		
		else if(c[0]=='*')
		{
	       
		y=pop();
		x=pop();
		z=x*y;
		push(z);
		}
		
		else 
		{
		x=atoi(c);
			
		push(x);
		}
        
		 

	}

        x=pop();

	printf("%d\n",x);

	return 0;

}


void initialize()
{
	top=0;
}

void push(int x)
{

s[top]=x;
 top++;
}

int pop()
{
top--;
return s[top];
}

int isEmpty()
{
if(top==0)return 1;
else return 0;
}

int isFull()
{
if(top >= MAX-1 )return 1;
else return 0;
}

