# stack
exp = [i for i in input().split()]
s = []

for lt in exp:
    if lt == '+':
        rhs = s.pop()
        lhs = s.pop()
        s.append(lhs + rhs)
    elif lt == '*':
        rhs = s.pop()
        lhs = s.pop()
        s.append(lhs * rhs)
    elif lt == '-':
        rhs = s.pop()
        lhs = s.pop()
        s.append(lhs - rhs)
    else:
        s.append(int(lt))
        
print(str(s[0])) i for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() i exp = [i for i in input().split()] exp [i for i in input().split()] s = [] s [] for lt in exp:
    if lt == '+':
        rhs = s.pop()
        lhs = s.pop()
        s.append(lhs + rhs)
    elif lt == '*':
        rhs = s.pop()
        lhs = s.pop()
        s.append(lhs * rhs)
    elif lt == '-':
        rhs = s.pop()
        lhs = s.pop()
        s.append(lhs - rhs)
    else:
        s.append(int(lt))
         lt exp if lt == '+':
        rhs = s.pop()
        lhs = s.pop()
        s.append(lhs + rhs)
    elif lt == '*':
        rhs = s.pop()
        lhs = s.pop()
        s.append(lhs * rhs)
    elif lt == '-':
        rhs = s.pop()
        lhs = s.pop()
        s.append(lhs - rhs)
    else:
        s.append(int(lt))
         lt == '+' lt '+' rhs = s.pop() rhs s.pop() s.pop s pop lhs = s.pop() lhs s.pop() s.pop s pop s.append(lhs + rhs) s.append s append lhs + rhs lhs rhs elif lt == '*':
        rhs = s.pop()
        lhs = s.pop()
        s.append(lhs * rhs)
     lt == '*' lt '*' rhs = s.pop() rhs s.pop() s.pop s pop lhs = s.pop() lhs s.pop() s.pop s pop s.append(lhs * rhs) s.append s append lhs * rhs lhs rhs elif lt == '-':
        rhs = s.pop()
        lhs = s.pop()
        s.append(lhs - rhs)
     lt == '-' lt '-' rhs = s.pop() rhs s.pop() s.pop s pop lhs = s.pop() lhs s.pop() s.pop s pop s.append(lhs - rhs) s.append s append lhs - rhs lhs rhs s.append(int(lt)) s.append s append int(lt) int lt print(str(s[0])) print str(s[0]) str s[0] s 0 rhs = s.pop() s.pop() rhs lhs = s.pop() s.pop() lhs lhs = s.pop() s.pop() lhs rhs = s.pop() s.pop() rhs s = [] [] s exp = [i for i in input().split()] [i for i in input().split()] exp rhs = s.pop() s.pop() rhs lhs = s.pop() s.pop() lhs
# stack
exp = [i for i in input().split()]
s = []

for lt in exp:
    if lt == '+':
        rhs = s.pop()
        lhs = s.pop()
        s.append(lhs + rhs)
    elif lt == '*':
        rhs = s.pop()
        lhs = s.pop()
        s.append(lhs * rhs)
    elif lt == '-':
        rhs = s.pop()
        lhs = s.pop()
        s.append(lhs - rhs)
    else:
        s.append(int(lt))
        
print(str(s[0]))