data = [str(i) for i in input().split()]
stack = []


def is_int(num) -> bool:
    try:
        int(num)
    except ValueError:
        return False
    return True


for d in data:
    if is_int(d):
        stack.append(d)
    else:
        if d == '+':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a + b)
        elif d == '-':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(b - a)
        elif d == '*':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a * b)
        else:
            raise ValueError('+, -, *以外の演算子が出現。')
print(stack.pop()) str(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() str(i) str i data = [str(i) for i in input().split()] data [str(i) for i in input().split()] stack = [] stack [] def is_int(num) -> bool:
    try:
        int(num)
    except ValueError:
        return False
    return True is_int try:
        int(num)
    except ValueError:
        return False
     except ValueError:
        return False
     return False False int(num) int num return True True num num for d in data:
    if is_int(d):
        stack.append(d)
    else:
        if d == '+':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a + b)
        elif d == '-':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(b - a)
        elif d == '*':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a * b)
        else:
            raise ValueError('+, -, *以外の演算子が出現。') d data if is_int(d):
        stack.append(d)
    else:
        if d == '+':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a + b)
        elif d == '-':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(b - a)
        elif d == '*':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a * b)
        else:
            raise ValueError('+, -, *以外の演算子が出現。') is_int(d) is_int d stack.append(d) stack.append stack append d if d == '+':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a + b)
        elif d == '-':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(b - a)
        elif d == '*':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a * b)
        else:
            raise ValueError('+, -, *以外の演算子が出現。') d == '+' d '+' a = int(stack.pop()) a int(stack.pop()) int stack.pop() stack.pop stack pop b = int(stack.pop()) b int(stack.pop()) int stack.pop() stack.pop stack pop stack.append(a + b) stack.append stack append a + b a b elif d == '-':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(b - a)
         d == '-' d '-' a = int(stack.pop()) a int(stack.pop()) int stack.pop() stack.pop stack pop b = int(stack.pop()) b int(stack.pop()) int stack.pop() stack.pop stack pop stack.append(b - a) stack.append stack append b - a b a elif d == '*':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a * b)
         d == '*' d '*' a = int(stack.pop()) a int(stack.pop()) int stack.pop() stack.pop stack pop b = int(stack.pop()) b int(stack.pop()) int stack.pop() stack.pop stack pop stack.append(a * b) stack.append stack append a * b a b raise ValueError('+, -, *以外の演算子が出現。') ValueError('+, -, *以外の演算子が出現。') ValueError '+, -, *以外の演算子が出現。' print(stack.pop()) print stack.pop() stack.pop stack pop b = int(stack.pop()) int(stack.pop()) b b = int(stack.pop()) int(stack.pop()) b data = [str(i) for i in input().split()] [str(i) for i in input().split()] data stack = [] [] stack def is_int(num) -> bool:
    try:
        int(num)
    except ValueError:
        return False
    return True def is_int(num) -> bool:
    try:
        int(num)
    except ValueError:
        return False
    return True is_int a = int(stack.pop()) int(stack.pop()) a a = int(stack.pop()) int(stack.pop()) a a = int(stack.pop()) int(stack.pop()) a b = int(stack.pop()) int(stack.pop()) b
data = [str(i) for i in input().split()]
stack = []


def is_int(num) -> bool:
    try:
        int(num)
    except ValueError:
        return False
    return True


for d in data:
    if is_int(d):
        stack.append(d)
    else:
        if d == '+':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a + b)
        elif d == '-':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(b - a)
        elif d == '*':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a * b)
        else:
            raise ValueError('+, -, *以外の演算子が出現。')
print(stack.pop())
