#include <stdio.h>
int main(void){
    int i=0;
    char a;
    int b[100];
    
    while(scanf("%c",&a) != EOF){
        
        if('0'<=a && a<='9'){
            b[i]=a-'0';
            i++;
        }
        
        else{
            switch(a){
            case '+' : b[i-2]+=b[i-1];
                        i--;
                        break;
            case '-' : b[i-2] -=b[i-1];
                        i--;
                        break;
            case '*' : b[i-2]*=b[i-1];
                        i--;
                        break;
            }
        }
    
    }
    
    printf("%d\n",b[0]);
    return 0;
}