let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', function() {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    console.log(calc(inputString[0].split(' ')));
});

const calc = (arr) => {
  const stack = [];
  for (let i=0; i<arr.length; i++) {
    const v = arr[i];
    switch (v) {
      case '+':
        stack.push(Number(stack.pop()) + Number(stack.pop()));
        break;
      case '-':
        const a = stack.pop();
        const b = stack.pop();
        stack.push(Number(b) - Number(a));
        break;
      case '*':
        stack.push(Number(stack.pop()) * Number(stack.pop()));
        break;
      default:
        stack.push(v);
    }
  }
  return stack.pop();
};

