#!/usr/bin/env python3
# -*- coding: utf-8 -*-

OPERATORS = ["+", "-", "*"]


def calc(symbols):
    stack = []
    for s in symbols:
        if s in OPERATORS:
            a = stack.pop()
            b = stack.pop()
            if s == "+":
                stack.append(b + a)
            elif s == "-":
                stack.append(b - a)
            elif s == "*":
                stack.append(b * a)
        else:
            stack.append(int(s))
    return stack[-1]


def main():
    print(calc(input().split()))


if __name__ == "__main__":
    main() OPERATORS = ["+", "-", "*"] OPERATORS ["+", "-", "*"] "+" "-" "*" def calc(symbols):
    stack = []
    for s in symbols:
        if s in OPERATORS:
            a = stack.pop()
            b = stack.pop()
            if s == "+":
                stack.append(b + a)
            elif s == "-":
                stack.append(b - a)
            elif s == "*":
                stack.append(b * a)
        else:
            stack.append(int(s))
    return stack[-1] calc stack = [] stack [] for s in symbols:
        if s in OPERATORS:
            a = stack.pop()
            b = stack.pop()
            if s == "+":
                stack.append(b + a)
            elif s == "-":
                stack.append(b - a)
            elif s == "*":
                stack.append(b * a)
        else:
            stack.append(int(s))
     s symbols if s in OPERATORS:
            a = stack.pop()
            b = stack.pop()
            if s == "+":
                stack.append(b + a)
            elif s == "-":
                stack.append(b - a)
            elif s == "*":
                stack.append(b * a)
        else:
            stack.append(int(s))
     s in OPERATORS s OPERATORS a = stack.pop() a stack.pop() stack.pop stack pop b = stack.pop() b stack.pop() stack.pop stack pop if s == "+":
                stack.append(b + a)
            elif s == "-":
                stack.append(b - a)
            elif s == "*":
                stack.append(b * a)
         s == "+" s "+" stack.append(b + a) stack.append stack append b + a b a elif s == "-":
                stack.append(b - a)
             s == "-" s "-" stack.append(b - a) stack.append stack append b - a b a elif s == "*":
                stack.append(b * a)
         s == "*" s "*" stack.append(b * a) stack.append stack append b * a b a stack.append(int(s)) stack.append stack append int(s) int s return stack[-1] stack[-1] stack -1 symbols symbols def main():
    print(calc(input().split())) main print(calc(input().split())) print calc(input().split()) calc input().split() ().split () input split if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    print(calc(input().split())) def main():
    print(calc(input().split())) main def calc(symbols):
    stack = []
    for s in symbols:
        if s in OPERATORS:
            a = stack.pop()
            b = stack.pop()
            if s == "+":
                stack.append(b + a)
            elif s == "-":
                stack.append(b - a)
            elif s == "*":
                stack.append(b * a)
        else:
            stack.append(int(s))
    return stack[-1] def calc(symbols):
    stack = []
    for s in symbols:
        if s in OPERATORS:
            a = stack.pop()
            b = stack.pop()
            if s == "+":
                stack.append(b + a)
            elif s == "-":
                stack.append(b - a)
            elif s == "*":
                stack.append(b * a)
        else:
            stack.append(int(s))
    return stack[-1] calc OPERATORS = ["+", "-", "*"] ["+", "-", "*"] OPERATORS
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

OPERATORS = ["+", "-", "*"]


def calc(symbols):
    stack = []
    for s in symbols:
        if s in OPERATORS:
            a = stack.pop()
            b = stack.pop()
            if s == "+":
                stack.append(b + a)
            elif s == "-":
                stack.append(b - a)
            elif s == "*":
                stack.append(b * a)
        else:
            stack.append(int(s))
    return stack[-1]


def main():
    print(calc(input().split()))


if __name__ == "__main__":
    main()