var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split(" ");
var arr=[];
for(var i=0;i<Arr.length;i++){
var v=Arr[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(v-0);
}
console.log(arr[0]);