function main(_stdin) {
    const stdin = _stdin.replace('\n', '').split(' ');
    console.log(compute(stdin));
}

function compute(chars) {
    const stack = [];
    for(const c of chars) {
        if(/\d+/.test(c)) {
            stack.push(c);
        } else {
            const rightOp = stack.pop();
            const leftOp = stack.pop();
            let a = `${leftOp}${c}${rightOp}`;
            a = a.replace('--', '+');
            stack.push(eval(a));
        }
    }
    return stack[0];
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));

