#include<stdio.h>

int main(){
    int i = 0,x,stack[10000];
    char c[100000];
    
    while(scanf("%s",c) != EOF){
        if(c[0] == '+'){
            stack[i-2] = stack[i-2] + stack[i-1];
            i--;
        }
        else if(c[0] == '-'){
            stack[i-2] = stack[i-2] - stack[i-1];
            i--;
        }
        else if(c[0] == '*'){
            stack[i-2] = stack[i-2] * stack[i-1];
            i--;
        }
        else{
            x = atoi(c);
            stack[i] = x;
            i++;
        }
    }

    printf("%d\n",stack[0]);

    return 0;
}
