# # a = []
# #
#b = [0 for i in range(10)]
# #
# # print(b)
# #
# # b.append(10) #
# #
# # b.insert(2,5)
# #
# # print(b)
# #
# # b.pop() #
# #
# # del b[1]
# #
# # b.remove(5)
# #
# # b.append(4)
# #
# # print(b)
# #
# # print(len(b)) #
# # print(sum(b))
# # print(max(b))
# # print(min(b))
# #
# # b.reverse()
# #
# # print('count',b.count(4))
# #
# print('index',b.index(79))
# #
# # print(b)
# #
# #
# # print(b[2:4])
# #
#print(b[-1])
# #
# # print(b[3:-1])
#
# # a = []
# # k = int(input())
# # for i in range(k):
# # n = int(input())
# # a.append(n)
# # c = 0
# # b = a.count(0)
# # for i in range(b):
# # c = a.index(0)
# # del a[c]
# # del a[c-1]
# #
# # print(sum(a))
#
# k = int(input())
# n = input()
# a = k // 3
# b = k / 3
# x = list(n)
# x.reverse()
# if a == b:
# for i in range(1, a):
# x.insert(4 * i - 1, ',')
# else:
# for i in range(1, a+1):
# x.insert(4*i-1, ',')
#
# x.reverse()
# for i in range(len(x)):
# print(x[i], end='')
# x = []
# # k = int(input())
# # for i in range(k):
# # a = input()
# # if a == 'top()':
# # if len(x) == 0:
# # print('-1')
# # else:
# # print(x[-1])
# #
# # elif a == 'pop()':
# # if len(x) != 0:
# # x.pop()
# # elif a == 'size()':
# # print(len(x))
# # elif a == 'empty()':
# # if len(x) == 0:
# # print('true')
# # else:
# # print('false')
# #
# # else:
# # xarr = a.split(' ')
# # x.append(xarr[1])
a = input().split()
x = []
for i in range(len(a)):
if a[i] != '*' and a[i] != '-' and a[i] != '+' and a[i] != ' ':
x.append(int(a[i]))
else:
if a[i] != ' ':
p = x.pop()
q = x.pop()
if a[i] == '*':
x.append(p*q)
elif a[i] == '-':
x.append(q-p)
else:
x.append(p+q)
print(x[-1])