import sys

ERROR_INPUT = 'input is invalid'
OPECODE = ['+', '-', '*']
STACK = []


def main():
    inp = get_input()
    print(calc_stack(li=inp))


def calc_stack(li):
    for l in li:
        if l in OPECODE:
            STACK.append(calc(right=STACK.pop(), left=STACK.pop(), ope=l))
        else:
            STACK.append(int(l))

    return STACK[0]


def calc(left, right, ope):
    if ope == '+':
        return left + right
    elif ope == '-':
        return left - right
    elif ope == '*':
        return left * right


def get_input():
    inp = input().split(' ')
    opecode_count = 0
    operand_count = 0

    for i in inp:
        if i in OPECODE:
            opecode_count += 1
        elif int(i) < 0 or int(i) > 10**6:
            print(ERROR_INPUT)
            sys.exit(1)
        else:
            operand_count += 1

    if opecode_count < 1 or opecode_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    if operand_count < 2 or operand_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    return inp


main() import sys sys ERROR_INPUT = 'input is invalid' ERROR_INPUT 'input is invalid' OPECODE = ['+', '-', '*'] OPECODE ['+', '-', '*'] '+' '-' '*' STACK = [] STACK [] def main():
    inp = get_input()
    print(calc_stack(li=inp)) main inp = get_input() inp get_input() get_input print(calc_stack(li=inp)) print calc_stack(li=inp) calc_stack li=inp li inp def calc_stack(li):
    for l in li:
        if l in OPECODE:
            STACK.append(calc(right=STACK.pop(), left=STACK.pop(), ope=l))
        else:
            STACK.append(int(l))

    return STACK[0] calc_stack for l in li:
        if l in OPECODE:
            STACK.append(calc(right=STACK.pop(), left=STACK.pop(), ope=l))
        else:
            STACK.append(int(l))

     l li if l in OPECODE:
            STACK.append(calc(right=STACK.pop(), left=STACK.pop(), ope=l))
        else:
            STACK.append(int(l))

     l in OPECODE l OPECODE STACK.append(calc(right=STACK.pop(), left=STACK.pop(), ope=l)) STACK.append STACK append calc(right=STACK.pop(), left=STACK.pop(), ope=l) calc right=STACK.pop() right STACK.pop() STACK.pop STACK pop left=STACK.pop() left STACK.pop() STACK.pop STACK pop ope=l ope l STACK.append(int(l)) STACK.append STACK append int(l) int l return STACK[0] STACK[0] STACK 0 li li def calc(left, right, ope):
    if ope == '+':
        return left + right
    elif ope == '-':
        return left - right
    elif ope == '*':
        return left * right calc if ope == '+':
        return left + right
    elif ope == '-':
        return left - right
    elif ope == '*':
        return left * right ope == '+' ope '+' return left + right left + right left right elif ope == '-':
        return left - right
     ope == '-' ope '-' return left - right left - right left right elif ope == '*':
        return left * right ope == '*' ope '*' return left * right left * right left right left left right right ope ope def get_input():
    inp = input().split(' ')
    opecode_count = 0
    operand_count = 0

    for i in inp:
        if i in OPECODE:
            opecode_count += 1
        elif int(i) < 0 or int(i) > 10**6:
            print(ERROR_INPUT)
            sys.exit(1)
        else:
            operand_count += 1

    if opecode_count < 1 or opecode_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    if operand_count < 2 or operand_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    return inp get_input inp = input().split(' ') inp input().split(' ') ().split () input split ' ' opecode_count = 0 opecode_count 0 operand_count = 0 operand_count 0 for i in inp:
        if i in OPECODE:
            opecode_count += 1
        elif int(i) < 0 or int(i) > 10**6:
            print(ERROR_INPUT)
            sys.exit(1)
        else:
            operand_count += 1

     i inp if i in OPECODE:
            opecode_count += 1
        elif int(i) < 0 or int(i) > 10**6:
            print(ERROR_INPUT)
            sys.exit(1)
        else:
            operand_count += 1

     i in OPECODE i OPECODE opecode_count += 1 opecode_count 1 elif int(i) < 0 or int(i) > 10**6:
            print(ERROR_INPUT)
            sys.exit(1)
         int(i) < 0 or int(i) > 10**6 int(i) < 0 int(i) int i 0 int(i) > 10**6 int(i) int i 10**6 10 6 print(ERROR_INPUT) print ERROR_INPUT sys.exit(1) sys.exit sys exit 1 operand_count += 1 operand_count 1 if opecode_count < 1 or opecode_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

     opecode_count < 1 or opecode_count > 100 opecode_count < 1 opecode_count 1 opecode_count > 100 opecode_count 100 print(ERROR_INPUT) print ERROR_INPUT sys.exit(1) sys.exit sys exit 1 if operand_count < 2 or operand_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

     operand_count < 2 or operand_count > 100 operand_count < 2 operand_count 2 operand_count > 100 operand_count 100 print(ERROR_INPUT) print ERROR_INPUT sys.exit(1) sys.exit sys exit 1 return inp inp main() main ERROR_INPUT = 'input is invalid' 'input is invalid' ERROR_INPUT OPECODE = ['+', '-', '*'] ['+', '-', '*'] OPECODE def main():
    inp = get_input()
    print(calc_stack(li=inp)) def main():
    inp = get_input()
    print(calc_stack(li=inp)) main STACK = [] [] STACK def calc_stack(li):
    for l in li:
        if l in OPECODE:
            STACK.append(calc(right=STACK.pop(), left=STACK.pop(), ope=l))
        else:
            STACK.append(int(l))

    return STACK[0] def calc_stack(li):
    for l in li:
        if l in OPECODE:
            STACK.append(calc(right=STACK.pop(), left=STACK.pop(), ope=l))
        else:
            STACK.append(int(l))

    return STACK[0] calc_stack def calc(left, right, ope):
    if ope == '+':
        return left + right
    elif ope == '-':
        return left - right
    elif ope == '*':
        return left * right def calc(left, right, ope):
    if ope == '+':
        return left + right
    elif ope == '-':
        return left - right
    elif ope == '*':
        return left * right calc def get_input():
    inp = input().split(' ')
    opecode_count = 0
    operand_count = 0

    for i in inp:
        if i in OPECODE:
            opecode_count += 1
        elif int(i) < 0 or int(i) > 10**6:
            print(ERROR_INPUT)
            sys.exit(1)
        else:
            operand_count += 1

    if opecode_count < 1 or opecode_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    if operand_count < 2 or operand_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    return inp def get_input():
    inp = input().split(' ')
    opecode_count = 0
    operand_count = 0

    for i in inp:
        if i in OPECODE:
            opecode_count += 1
        elif int(i) < 0 or int(i) > 10**6:
            print(ERROR_INPUT)
            sys.exit(1)
        else:
            operand_count += 1

    if opecode_count < 1 or opecode_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    if operand_count < 2 or operand_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    return inp get_input
import sys

ERROR_INPUT = 'input is invalid'
OPECODE = ['+', '-', '*']
STACK = []


def main():
    inp = get_input()
    print(calc_stack(li=inp))


def calc_stack(li):
    for l in li:
        if l in OPECODE:
            STACK.append(calc(right=STACK.pop(), left=STACK.pop(), ope=l))
        else:
            STACK.append(int(l))

    return STACK[0]


def calc(left, right, ope):
    if ope == '+':
        return left + right
    elif ope == '-':
        return left - right
    elif ope == '*':
        return left * right


def get_input():
    inp = input().split(' ')
    opecode_count = 0
    operand_count = 0

    for i in inp:
        if i in OPECODE:
            opecode_count += 1
        elif int(i) < 0 or int(i) > 10**6:
            print(ERROR_INPUT)
            sys.exit(1)
        else:
            operand_count += 1

    if opecode_count < 1 or opecode_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    if operand_count < 2 or operand_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    return inp


main()