expressions = raw_input( ).split( " " )
stack = []
for op in expressions:
	if "+" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a + b )
	elif "-" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a - b	)
	elif "*" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a * b )
	else:
		stack.append( int( op ) )
print( stack.pop( ) ) expressions = raw_input( ).split( " " ) expressions raw_input( ).split( " " ) ( ).split ( ) raw_input split " " stack = [] stack [] for op in expressions:
	if "+" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a + b )
	elif "-" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a - b	)
	elif "*" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a * b )
	else:
		stack.append( int( op ) ) op expressions if "+" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a + b )
	elif "-" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a - b	)
	elif "*" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a * b )
	else:
		stack.append( int( op ) ) "+" == op "+" op b = stack.pop( ) b stack.pop( ) stack.pop stack pop a = stack.pop( ) a stack.pop( ) stack.pop stack pop stack.append( a + b ) stack.append stack append a + b a b elif "-" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a - b	)
	 "-" == op "-" op b = stack.pop( ) b stack.pop( ) stack.pop stack pop a = stack.pop( ) a stack.pop( ) stack.pop stack pop stack.append( a - b	) stack.append stack append a - b a b elif "*" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a * b )
	 "*" == op "*" op b = stack.pop( ) b stack.pop( ) stack.pop stack pop a = stack.pop( ) a stack.pop( ) stack.pop stack pop stack.append( a * b ) stack.append stack append a * b a b stack.append( int( op ) ) stack.append stack append int( op ) int op print( stack.pop( ) ) print stack.pop( ) stack.pop stack pop b = stack.pop( ) stack.pop( ) b a = stack.pop( ) stack.pop( ) a b = stack.pop( ) stack.pop( ) b b = stack.pop( ) stack.pop( ) b a = stack.pop( ) stack.pop( ) a a = stack.pop( ) stack.pop( ) a expressions = raw_input( ).split( " " ) raw_input( ).split( " " ) expressions stack = [] [] stack
expressions = raw_input( ).split( " " )
stack = []
for op in expressions:
	if "+" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a + b )
	elif "-" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a - b	)
	elif "*" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a * b )
	else:
		stack.append( int( op ) )
print( stack.pop( ) )