import sys


Stack = []

def push(x):
    Stack.append(x)

def pop():
    Stack.pop(-1)


def cul(exp):
    for val in exp:
        if val in ["+", "-", "*"]:
            a = int(Stack[-2])
            b = int(Stack[-1])
            if val == "+":
                x = a + b
            elif val == "-":
                x = a - b
            elif val == "*":
                x = a * b
            for i in range(2):
                pop()
            push(x)
        else:
            push(val)

    return Stack[0]


if __name__ == "__main__":
    exp = sys.stdin.read().strip().split(" ")
    ans = cul(exp)
    print ans import sys sys Stack = [] Stack [] def push(x):
    Stack.append(x) push Stack.append(x) Stack.append Stack append x x x def pop():
    Stack.pop(-1) pop Stack.pop(-1) Stack.pop Stack pop -1 def cul(exp):
    for val in exp:
        if val in ["+", "-", "*"]:
            a = int(Stack[-2])
            b = int(Stack[-1])
            if val == "+":
                x = a + b
            elif val == "-":
                x = a - b
            elif val == "*":
                x = a * b
            for i in range(2):
                pop()
            push(x)
        else:
            push(val)

    return Stack[0] cul for val in exp:
        if val in ["+", "-", "*"]:
            a = int(Stack[-2])
            b = int(Stack[-1])
            if val == "+":
                x = a + b
            elif val == "-":
                x = a - b
            elif val == "*":
                x = a * b
            for i in range(2):
                pop()
            push(x)
        else:
            push(val)

     val exp if val in ["+", "-", "*"]:
            a = int(Stack[-2])
            b = int(Stack[-1])
            if val == "+":
                x = a + b
            elif val == "-":
                x = a - b
            elif val == "*":
                x = a * b
            for i in range(2):
                pop()
            push(x)
        else:
            push(val)

     val in ["+", "-", "*"] val ["+", "-", "*"] "+" "-" "*" a = int(Stack[-2]) a int(Stack[-2]) int Stack[-2] Stack -2 b = int(Stack[-1]) b int(Stack[-1]) int Stack[-1] Stack -1 if val == "+":
                x = a + b
            elif val == "-":
                x = a - b
            elif val == "*":
                x = a * b
             val == "+" val "+" x = a + b x a + b a b elif val == "-":
                x = a - b
             val == "-" val "-" x = a - b x a - b a b elif val == "*":
                x = a * b
             val == "*" val "*" x = a * b x a * b a b for i in range(2):
                pop()
             i range(2) range 2 pop() pop push(x) push x push(val) push val return Stack[0] Stack[0] Stack 0 exp exp if __name__ == "__main__":
    exp = sys.stdin.read().strip().split(" ")
    ans = cul(exp)
    print ans __name__ == "__main__" __name__ "__main__" exp = sys.stdin.read().strip().split(" ") exp sys.stdin.read().strip().split(" ") sys.stdin.read().strip().split sys.stdin.read().strip() sys.stdin.read().strip sys.stdin.read() sys.stdin.read sys.stdin sys stdin read strip split " " ans = cul(exp) ans cul(exp) cul exp print def push(x):
    Stack.append(x) def push(x):
    Stack.append(x) push ans = cul(exp) cul(exp) ans exp = sys.stdin.read().strip().split(" ") sys.stdin.read().strip().split(" ") exp def cul(exp):
    for val in exp:
        if val in ["+", "-", "*"]:
            a = int(Stack[-2])
            b = int(Stack[-1])
            if val == "+":
                x = a + b
            elif val == "-":
                x = a - b
            elif val == "*":
                x = a * b
            for i in range(2):
                pop()
            push(x)
        else:
            push(val)

    return Stack[0] def cul(exp):
    for val in exp:
        if val in ["+", "-", "*"]:
            a = int(Stack[-2])
            b = int(Stack[-1])
            if val == "+":
                x = a + b
            elif val == "-":
                x = a - b
            elif val == "*":
                x = a * b
            for i in range(2):
                pop()
            push(x)
        else:
            push(val)

    return Stack[0] cul Stack = [] [] Stack def pop():
    Stack.pop(-1) def pop():
    Stack.pop(-1) pop
import sys


Stack = []

def push(x):
    Stack.append(x)

def pop():
    Stack.pop(-1)


def cul(exp):
    for val in exp:
        if val in ["+", "-", "*"]:
            a = int(Stack[-2])
            b = int(Stack[-1])
            if val == "+":
                x = a + b
            elif val == "-":
                x = a - b
            elif val == "*":
                x = a * b
            for i in range(2):
                pop()
            push(x)
        else:
            push(val)

    return Stack[0]


if __name__ == "__main__":
    exp = sys.stdin.read().strip().split(" ")
    ans = cul(exp)
    print ans