#include <stdio.h>
#include <stdlib.h>

int main(void){
    int x;
    char s[100];
    int stack[100];
    int c = 0;
    
    while(scanf("%s", s) != EOF){
        if ( s[0] == '+' ){
            stack[c-2] = stack[c-2] + stack[c-1];
            c--;
        } else if ( s[0] == '-' ){
            stack[c-2] = stack[c-2] - stack[c-1];
            c--;
        } else if ( s[0] == '*' ){
            stack[c-2] = stack[c-2] * stack[c-1];
            c--;
        } else {
            x = atoi(s);
            stack[c] = x;
            c++;
        }
    }
    printf("%d\n", stack[0]);
    
    return 0;
}

