def do_calc(data):
    from collections import deque
    s = deque()  # ??????????????¨??????????????????
    while data:
        elem = data[0]
        data = data[1:]
        if elem == '+' or elem == '-' or elem == '*':
            a = s.pop()
            b = s.pop()
            if elem == '+':
                s.append(b + a)
            elif elem == '-':
                s.append(b - a)
            elif elem == '*':
                s.append(b * a)
        else:
            s.append(int(elem))
    return s.pop()


if __name__ == '__main__':
    # ??????????????\???
    data = [x for x in input().split(' ')]
    # data = ['1', '2', '+', '3', '4', '-', '*']

    # ???????????????
    result = do_calc(data)

    # ???????????????
    print(result) def do_calc(data):
    from collections import deque
    s = deque()  # ??????????????¨??????????????????
    while data:
        elem = data[0]
        data = data[1:]
        if elem == '+' or elem == '-' or elem == '*':
            a = s.pop()
            b = s.pop()
            if elem == '+':
                s.append(b + a)
            elif elem == '-':
                s.append(b - a)
            elif elem == '*':
                s.append(b * a)
        else:
            s.append(int(elem))
    return s.pop() do_calc from collections import deque s = deque() s deque() deque while data:
        elem = data[0]
        data = data[1:]
        if elem == '+' or elem == '-' or elem == '*':
            a = s.pop()
            b = s.pop()
            if elem == '+':
                s.append(b + a)
            elif elem == '-':
                s.append(b - a)
            elif elem == '*':
                s.append(b * a)
        else:
            s.append(int(elem))
     data elem = data[0] elem data[0] data 0 data = data[1:] data data[1:] data 1: 1 if elem == '+' or elem == '-' or elem == '*':
            a = s.pop()
            b = s.pop()
            if elem == '+':
                s.append(b + a)
            elif elem == '-':
                s.append(b - a)
            elif elem == '*':
                s.append(b * a)
        else:
            s.append(int(elem))
     elem == '+' or elem == '-' or elem == '*' elem == '+' or elem == '-' elem == '+' elem '+' elem == '-' elem '-' elem == '*' elem '*' a = s.pop() a s.pop() s.pop s pop b = s.pop() b s.pop() s.pop s pop if elem == '+':
                s.append(b + a)
            elif elem == '-':
                s.append(b - a)
            elif elem == '*':
                s.append(b * a)
         elem == '+' elem '+' s.append(b + a) s.append s append b + a b a elif elem == '-':
                s.append(b - a)
             elem == '-' elem '-' s.append(b - a) s.append s append b - a b a elif elem == '*':
                s.append(b * a)
         elem == '*' elem '*' s.append(b * a) s.append s append b * a b a s.append(int(elem)) s.append s append int(elem) int elem return s.pop() s.pop() s.pop s pop data data if __name__ == '__main__':
    # ??????????????\???
    data = [x for x in input().split(' ')]
    # data = ['1', '2', '+', '3', '4', '-', '*']

    # ???????????????
    result = do_calc(data)

    # ???????????????
    print(result) __name__ == '__main__' __name__ '__main__' x for x in input().split(' ') for x in input().split(' ') x input().split(' ') ().split () input split ' ' for x in input().split(' ') x data = [x for x in input().split(' ')] data [x for x in input().split(' ')] result = do_calc(data) result do_calc(data) do_calc data print(result) print result data = [x for x in input().split(' ')] [x for x in input().split(' ')] data def do_calc(data):
    from collections import deque
    s = deque()  # ??????????????¨??????????????????
    while data:
        elem = data[0]
        data = data[1:]
        if elem == '+' or elem == '-' or elem == '*':
            a = s.pop()
            b = s.pop()
            if elem == '+':
                s.append(b + a)
            elif elem == '-':
                s.append(b - a)
            elif elem == '*':
                s.append(b * a)
        else:
            s.append(int(elem))
    return s.pop() def do_calc(data):
    from collections import deque
    s = deque()  # ??????????????¨??????????????????
    while data:
        elem = data[0]
        data = data[1:]
        if elem == '+' or elem == '-' or elem == '*':
            a = s.pop()
            b = s.pop()
            if elem == '+':
                s.append(b + a)
            elif elem == '-':
                s.append(b - a)
            elif elem == '*':
                s.append(b * a)
        else:
            s.append(int(elem))
    return s.pop() do_calc result = do_calc(data) do_calc(data) result
def do_calc(data):
    from collections import deque
    s = deque()  # ??????????????¨??????????????????
    while data:
        elem = data[0]
        data = data[1:]
        if elem == '+' or elem == '-' or elem == '*':
            a = s.pop()
            b = s.pop()
            if elem == '+':
                s.append(b + a)
            elif elem == '-':
                s.append(b - a)
            elif elem == '*':
                s.append(b * a)
        else:
            s.append(int(elem))
    return s.pop()


if __name__ == '__main__':
    # ??????????????\???
    data = [x for x in input().split(' ')]
    # data = ['1', '2', '+', '3', '4', '-', '*']

    # ???????????????
    result = do_calc(data)

    # ???????????????
    print(result)