s[100],top,a,b;
char t[100];
push(x){s[++top]=x;}
pop(){return s[top--];}
main(){
    for(;~scanf("%s",t);){
        switch(*t){
            case'+':a=pop();b=pop();push(a+b);break;
            case'-':a=pop();b=pop();push(b-a);break;
            case'*':a=pop();b=pop();push(a*b);break;
            default:push(atoi(t));
        }
    }
    printf("%d\n",s[1]);
}