//config = {input: 'tmp', newline: '\r\n'}; // win
config = {input: '/dev/stdin', newline: '\n'}; //linux

stack = [];
require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(' ')
  .forEach(function (symbol) {
    if (symbol === '+') stack.push(stack.pop() + stack.pop());
    else if (symbol === '-') stack.push(-stack.pop() + stack.pop());
    else if (symbol === '*') stack.push(stack.pop() * stack.pop());
    else stack.push(parseInt(symbol, 10));
});

console.log(stack[0]);