const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

const solve = arr => {
    const helper = (xs, stack) => {
        if (xs.length === 0) return stack[0];
        const hd = xs[0];
        const tl = xs.slice(1);
        if (hd === '+') {
            const snd = stack.pop();
            const fst = stack.pop();
            stack.push(fst + snd);
        } else if (hd === '-') {
            const snd = stack.pop();
            const fst = stack.pop();
            stack.push(fst - snd);
        } else if (hd === '*') {
            const snd = stack.pop();
            const fst = stack.pop();
            stack.push(fst * snd);
        } else {
            stack.push(parseFloat(hd));
        }
        return helper(tl, stack); 
    };

    return helper(arr, []);
};

console.log(solve(line[0].split(' ')));

