function stack(A) {
  let arr = [];
  for (let i = 0; i < A.length; i++) {
    let v = A[i];
    if (v == "+") {
      arr.push(arr.pop() + arr.pop());
      continue;
    }
    if (v == "-") {
      arr.push(-1 * arr.pop() + arr.pop());
      continue;
    }
    if (v == "*") {
      arr.push(arr.pop() * arr.pop());
      continue;
    }
    arr.push(Number(v));
  }
  console.log(Number(arr));
}
const lines = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");
const ary = lines[0].split(" ");
stack(ary);


