const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void (async function () {
const input = await readline();
const stack = [];
let chars = [];
for (const c of input) {
if (c == ")" || c == " ") {
if (chars.length > 0) {
stack.push(chars.join(""));
chars = [];
}
}
if (c == ")") {
const num2 = Number(stack.pop());
const num1 = Number(stack.pop());
const op = stack.pop();
let res = 0;
switch (op) {
case "add":
res = num1 + num2;
break;
case "sub":
res = num1 - num2;
break;
case "mul":
res = num1 * num2;
break;
default: {
if (num2 == 0) return console.log("error");
res = num1 / num2;
break;
}
}
stack.push(res);
}
if (c !== "(" && c !== " " && c !== ")") {
chars.push(c);
}
}
console.log(stack.pop());
})();