data = input().split(" ");

def reverse_polish_notation(data):
    operands = [];
    for n in data:
        if n not in "*+-":
            operands.append(int(n));
        else:
            operand_second = operands.pop();
            operand_first = operands.pop();
            operands.append(calculate(n, operand_first, operand_second));
    return operands[0];

def calculate(operator, a, b):
    if operator == "*":
        return a * b;
    elif operator == "-":
        return a - b;
    elif operator == "+":
        return a + b;

print(reverse_polish_notation(data)); data = input().split(" ") data input().split(" ") ().split () input split " " def reverse_polish_notation(data):
    operands = [];
    for n in data:
        if n not in "*+-":
            operands.append(int(n));
        else:
            operand_second = operands.pop();
            operand_first = operands.pop();
            operands.append(calculate(n, operand_first, operand_second));
    return operands[0]; reverse_polish_notation operands = [] operands [] for n in data:
        if n not in "*+-":
            operands.append(int(n));
        else:
            operand_second = operands.pop();
            operand_first = operands.pop();
            operands.append(calculate(n, operand_first, operand_second));
     n data if n not in "*+-":
            operands.append(int(n));
        else:
            operand_second = operands.pop();
            operand_first = operands.pop();
            operands.append(calculate(n, operand_first, operand_second));
     n not in "*+-" n "*+-" operands.append(int(n)) operands.append operands append int(n) int n operand_second = operands.pop() operand_second operands.pop() operands.pop operands pop operand_first = operands.pop() operand_first operands.pop() operands.pop operands pop operands.append(calculate(n, operand_first, operand_second)) operands.append operands append calculate(n, operand_first, operand_second) calculate n operand_first operand_second return operands[0] operands[0] operands 0 data data def calculate(operator, a, b):
    if operator == "*":
        return a * b;
    elif operator == "-":
        return a - b;
    elif operator == "+":
        return a + b; calculate if operator == "*":
        return a * b;
    elif operator == "-":
        return a - b;
    elif operator == "+":
        return a + b; operator == "*" operator "*" return a * b a * b a b elif operator == "-":
        return a - b;
     operator == "-" operator "-" return a - b a - b a b elif operator == "+":
        return a + b; operator == "+" operator "+" return a + b a + b a b operator operator a a b b print(reverse_polish_notation(data)) print reverse_polish_notation(data) reverse_polish_notation data data = input().split(" ") input().split(" ") data def calculate(operator, a, b):
    if operator == "*":
        return a * b;
    elif operator == "-":
        return a - b;
    elif operator == "+":
        return a + b; def calculate(operator, a, b):
    if operator == "*":
        return a * b;
    elif operator == "-":
        return a - b;
    elif operator == "+":
        return a + b; calculate def reverse_polish_notation(data):
    operands = [];
    for n in data:
        if n not in "*+-":
            operands.append(int(n));
        else:
            operand_second = operands.pop();
            operand_first = operands.pop();
            operands.append(calculate(n, operand_first, operand_second));
    return operands[0]; def reverse_polish_notation(data):
    operands = [];
    for n in data:
        if n not in "*+-":
            operands.append(int(n));
        else:
            operand_second = operands.pop();
            operand_first = operands.pop();
            operands.append(calculate(n, operand_first, operand_second));
    return operands[0]; reverse_polish_notation
data = input().split(" ");

def reverse_polish_notation(data):
    operands = [];
    for n in data:
        if n not in "*+-":
            operands.append(int(n));
        else:
            operand_second = operands.pop();
            operand_first = operands.pop();
            operands.append(calculate(n, operand_first, operand_second));
    return operands[0];

def calculate(operator, a, b):
    if operator == "*":
        return a * b;
    elif operator == "-":
        return a - b;
    elif operator == "+":
        return a + b;

print(reverse_polish_notation(data));
