def calc(stack, s):
	a = stack.pop()
	b = stack.pop()
	if s=='+':
		stack.append(b+a)
	elif s=='-':
		stack.append(b-a)
	elif s=='*':
		stack.append(b*a)

		

S = list(input().split())

stack = []
for s in S:
	if s in ['+', '-', '*']:
		calc(stack, s)
	else:
		stack.append(int(s))

print(stack[0]) def calc(stack, s):
	a = stack.pop()
	b = stack.pop()
	if s=='+':
		stack.append(b+a)
	elif s=='-':
		stack.append(b-a)
	elif s=='*':
		stack.append(b*a)

		 calc a = stack.pop() a stack.pop() stack.pop stack pop b = stack.pop() b stack.pop() stack.pop stack pop if s=='+':
		stack.append(b+a)
	elif s=='-':
		stack.append(b-a)
	elif s=='*':
		stack.append(b*a)

		 s=='+' s '+' stack.append(b+a) stack.append stack append b+a b a elif s=='-':
		stack.append(b-a)
	 s=='-' s '-' stack.append(b-a) stack.append stack append b-a b a elif s=='*':
		stack.append(b*a)

		 s=='*' s '*' stack.append(b*a) stack.append stack append b*a b a stack stack s s S = list(input().split()) S list(input().split()) list input().split() ().split () input split stack = [] stack [] for s in S:
	if s in ['+', '-', '*']:
		calc(stack, s)
	else:
		stack.append(int(s)) s S if s in ['+', '-', '*']:
		calc(stack, s)
	else:
		stack.append(int(s)) s in ['+', '-', '*'] s ['+', '-', '*'] '+' '-' '*' calc(stack, s) calc stack s stack.append(int(s)) stack.append stack append int(s) int s print(stack[0]) print stack[0] stack 0 def calc(stack, s):
	a = stack.pop()
	b = stack.pop()
	if s=='+':
		stack.append(b+a)
	elif s=='-':
		stack.append(b-a)
	elif s=='*':
		stack.append(b*a)

		 def calc(stack, s):
	a = stack.pop()
	b = stack.pop()
	if s=='+':
		stack.append(b+a)
	elif s=='-':
		stack.append(b-a)
	elif s=='*':
		stack.append(b*a)

		 calc stack = [] [] stack S = list(input().split()) list(input().split()) S
def calc(stack, s):
	a = stack.pop()
	b = stack.pop()
	if s=='+':
		stack.append(b+a)
	elif s=='-':
		stack.append(b-a)
	elif s=='*':
		stack.append(b*a)

		

S = list(input().split())

stack = []
for s in S:
	if s in ['+', '-', '*']:
		calc(stack, s)
	else:
		stack.append(int(s))

print(stack[0])
