def main():
    A = input().split()
    l = []
    operator = None
    for character in A:
        if character in ["+", "-", "*"]:
            if character == "+":
                l.append(l.pop()+l.pop())
            elif character == "-":
                l.append(-l.pop()+l.pop())
            else:
                l.append(l.pop()*l.pop())
        else:
            l.append(int(character))
    print(l[0])




if __name__ == "__main__":
    import os
    import sys
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main() def main():
    A = input().split()
    l = []
    operator = None
    for character in A:
        if character in ["+", "-", "*"]:
            if character == "+":
                l.append(l.pop()+l.pop())
            elif character == "-":
                l.append(-l.pop()+l.pop())
            else:
                l.append(l.pop()*l.pop())
        else:
            l.append(int(character))
    print(l[0]) main A = input().split() A input().split() ().split () input split l = [] l [] operator = None operator None for character in A:
        if character in ["+", "-", "*"]:
            if character == "+":
                l.append(l.pop()+l.pop())
            elif character == "-":
                l.append(-l.pop()+l.pop())
            else:
                l.append(l.pop()*l.pop())
        else:
            l.append(int(character))
     character A if character in ["+", "-", "*"]:
            if character == "+":
                l.append(l.pop()+l.pop())
            elif character == "-":
                l.append(-l.pop()+l.pop())
            else:
                l.append(l.pop()*l.pop())
        else:
            l.append(int(character))
     character in ["+", "-", "*"] character ["+", "-", "*"] "+" "-" "*" if character == "+":
                l.append(l.pop()+l.pop())
            elif character == "-":
                l.append(-l.pop()+l.pop())
            else:
                l.append(l.pop()*l.pop())
         character == "+" character "+" l.append(l.pop()+l.pop()) l.append l append l.pop()+l.pop() l.pop() l.pop l pop l.pop() l.pop l pop elif character == "-":
                l.append(-l.pop()+l.pop())
             character == "-" character "-" l.append(-l.pop()+l.pop()) l.append l append -l.pop()+l.pop() -l.pop() l.pop() l.pop l pop l.pop() l.pop l pop l.append(l.pop()*l.pop()) l.append l append l.pop()*l.pop() l.pop() l.pop l pop l.pop() l.pop l pop l.append(int(character)) l.append l append int(character) int character print(l[0]) print l[0] l 0 if __name__ == "__main__":
    import os
    import sys
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main() __name__ == "__main__" __name__ "__main__" import os os import sys sys if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main() len(sys.argv) > 1 len(sys.argv) len sys.argv sys argv 1 if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
     sys.argv[1] == "-d" sys.argv[1] sys.argv sys argv 1 "-d" fd = os.open("input.txt", os.O_RDONLY) fd os.open("input.txt", os.O_RDONLY) os.open os open "input.txt" os.O_RDONLY os O_RDONLY os.dup2(fd, sys.stdin.fileno()) os.dup2 os dup2 fd sys.stdin.fileno() sys.stdin.fileno sys.stdin sys stdin fileno main() main main() main def main():
    A = input().split()
    l = []
    operator = None
    for character in A:
        if character in ["+", "-", "*"]:
            if character == "+":
                l.append(l.pop()+l.pop())
            elif character == "-":
                l.append(-l.pop()+l.pop())
            else:
                l.append(l.pop()*l.pop())
        else:
            l.append(int(character))
    print(l[0]) def main():
    A = input().split()
    l = []
    operator = None
    for character in A:
        if character in ["+", "-", "*"]:
            if character == "+":
                l.append(l.pop()+l.pop())
            elif character == "-":
                l.append(-l.pop()+l.pop())
            else:
                l.append(l.pop()*l.pop())
        else:
            l.append(int(character))
    print(l[0]) main fd = os.open("input.txt", os.O_RDONLY) os.open("input.txt", os.O_RDONLY) fd
def main():
    A = input().split()
    l = []
    operator = None
    for character in A:
        if character in ["+", "-", "*"]:
            if character == "+":
                l.append(l.pop()+l.pop())
            elif character == "-":
                l.append(-l.pop()+l.pop())
            else:
                l.append(l.pop()*l.pop())
        else:
            l.append(int(character))
    print(l[0])




if __name__ == "__main__":
    import os
    import sys
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()