
def solve(tokens):
    stack = []

    for token in tokens:
        if token == "+":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 + t2)
        elif token == "-":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t2 - t1)
        elif token == "*":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 * t2)
        else:
            stack.append(int(token))

    return stack.pop()


def main():
    print solve(raw_input().split())


if __name__ == "__main__":
    main() def solve(tokens):
    stack = []

    for token in tokens:
        if token == "+":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 + t2)
        elif token == "-":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t2 - t1)
        elif token == "*":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 * t2)
        else:
            stack.append(int(token))

    return stack.pop() solve stack = [] stack [] for token in tokens:
        if token == "+":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 + t2)
        elif token == "-":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t2 - t1)
        elif token == "*":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 * t2)
        else:
            stack.append(int(token))

     token tokens if token == "+":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 + t2)
        elif token == "-":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t2 - t1)
        elif token == "*":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 * t2)
        else:
            stack.append(int(token))

     token == "+" token "+" t1 = stack.pop() t1 stack.pop() stack.pop stack pop t2 = stack.pop() t2 stack.pop() stack.pop stack pop stack.append(t1 + t2) stack.append stack append t1 + t2 t1 t2 elif token == "-":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t2 - t1)
         token == "-" token "-" t1 = stack.pop() t1 stack.pop() stack.pop stack pop t2 = stack.pop() t2 stack.pop() stack.pop stack pop stack.append(t2 - t1) stack.append stack append t2 - t1 t2 t1 elif token == "*":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 * t2)
         token == "*" token "*" t1 = stack.pop() t1 stack.pop() stack.pop stack pop t2 = stack.pop() t2 stack.pop() stack.pop stack pop stack.append(t1 * t2) stack.append stack append t1 * t2 t1 t2 stack.append(int(token)) stack.append stack append int(token) int token return stack.pop() stack.pop() stack.pop stack pop tokens tokens def main():
    print solve(raw_input().split()) main print solve(raw_input().split()) solve raw_input().split() ().split () raw_input split if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def solve(tokens):
    stack = []

    for token in tokens:
        if token == "+":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 + t2)
        elif token == "-":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t2 - t1)
        elif token == "*":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 * t2)
        else:
            stack.append(int(token))

    return stack.pop() def solve(tokens):
    stack = []

    for token in tokens:
        if token == "+":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 + t2)
        elif token == "-":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t2 - t1)
        elif token == "*":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 * t2)
        else:
            stack.append(int(token))

    return stack.pop() solve def main():
    print solve(raw_input().split()) def main():
    print solve(raw_input().split()) main

def solve(tokens):
    stack = []

    for token in tokens:
        if token == "+":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 + t2)
        elif token == "-":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t2 - t1)
        elif token == "*":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 * t2)
        else:
            stack.append(int(token))

    return stack.pop()


def main():
    print solve(raw_input().split())


if __name__ == "__main__":
    main()