#include <stdio.h>
int i,s[100],top,a,b;
char t;
void push(int x){
    top++;
    s[top]=x;
}
int pop(){
    top--;
    return s[top+1];
}
int main(void){
    for(;~scanf("%c ",&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(t-48);
        }
    }
    printf("%d\n",s[1]);
}