def reverse_polish_notation(A):
	ops = {'+': lambda a, b: b + a,
	       '-': lambda a, b: b - a,
	       '*': lambda a, b: b * a}

	stack = []

	for i in A:
		if i in ops:
			stack.append(ops[i](stack.pop(), stack.pop()))
		else:
			stack.append(int(i))

	return stack[0]

if __name__ == '__main__':
	A = list(input().split())
	print(reverse_polish_notation(A)) def reverse_polish_notation(A):
	ops = {'+': lambda a, b: b + a,
	       '-': lambda a, b: b - a,
	       '*': lambda a, b: b * a}

	stack = []

	for i in A:
		if i in ops:
			stack.append(ops[i](stack.pop(), stack.pop()))
		else:
			stack.append(int(i))

	return stack[0] reverse_polish_notation ops = {'+': lambda a, b: b + a,
	       '-': lambda a, b: b - a,
	       '*': lambda a, b: b * a} ops {'+': lambda a, b: b + a,
	       '-': lambda a, b: b - a,
	       '*': lambda a, b: b * a} '+' '+' lambda a, b: b + a b + a b a a b '-' '-' lambda a, b: b - a b - a b a a b '*' '*' lambda a, b: b * a b * a b a a b stack = [] stack [] for i in A:
		if i in ops:
			stack.append(ops[i](stack.pop(), stack.pop()))
		else:
			stack.append(int(i))

	 i A if i in ops:
			stack.append(ops[i](stack.pop(), stack.pop()))
		else:
			stack.append(int(i))

	 i in ops i ops stack.append(ops[i](stack.pop(), stack.pop())) stack.append stack append ops[i](stack.pop(), stack.pop()) [i] ops i stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop stack.append(int(i)) stack.append stack append int(i) int i return stack[0] stack[0] stack 0 A A if __name__ == '__main__':
	A = list(input().split())
	print(reverse_polish_notation(A)) __name__ == '__main__' __name__ '__main__' A = list(input().split()) A list(input().split()) list input().split() ().split () input split print(reverse_polish_notation(A)) print reverse_polish_notation(A) reverse_polish_notation A A = list(input().split()) list(input().split()) A def reverse_polish_notation(A):
	ops = {'+': lambda a, b: b + a,
	       '-': lambda a, b: b - a,
	       '*': lambda a, b: b * a}

	stack = []

	for i in A:
		if i in ops:
			stack.append(ops[i](stack.pop(), stack.pop()))
		else:
			stack.append(int(i))

	return stack[0] def reverse_polish_notation(A):
	ops = {'+': lambda a, b: b + a,
	       '-': lambda a, b: b - a,
	       '*': lambda a, b: b * a}

	stack = []

	for i in A:
		if i in ops:
			stack.append(ops[i](stack.pop(), stack.pop()))
		else:
			stack.append(int(i))

	return stack[0] reverse_polish_notation
def reverse_polish_notation(A):
	ops = {'+': lambda a, b: b + a,
	       '-': lambda a, b: b - a,
	       '*': lambda a, b: b * a}

	stack = []

	for i in A:
		if i in ops:
			stack.append(ops[i](stack.pop(), stack.pop()))
		else:
			stack.append(int(i))

	return stack[0]

if __name__ == '__main__':
	A = list(input().split())
	print(reverse_polish_notation(A))