process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  reversePorandCalcuration(lines[0].split(" "));
});

function reversePorandCalcuration(tokens) {
  const operands = [];
  function getOperand() {
    const after = operands.pop();
    const before = operands.pop();
    return [before, after];
  }
  tokens.forEach((token) => {
    let o1, o2;
    switch (token) {
      case "+":
        [o1, o2] = getOperand();
        operands.push(o1 + o2);
        break;
      case "-":
        [o1, o2] = getOperand();
        operands.push(o1 - o2);
        break;
      case "*":
        [o1, o2] = getOperand();
        operands.push(o1 * o2);
        break;
      default:
        operands.push(Number(token));
        break;
    }
  });
  console.log(operands[0]);
}

