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

void pop(){
    
}

void push(){
    
}

int main(int argc, const char * argv[]) {
    
    int x[100];
    char s[100];
    int top = 0;
    
    while(scanf("%s",s) != EOF){
        if (s[0] == '+') {
            top--;
            x[top-1] = x[top-1] + x[top];
        }else if(s[0] == '-'){
            top--;
            x[top-1] = x[top-1] - x[top];
        }else if(s[0] == '*'){
            top--;
            x[top-1] = x[top-1] * x[top];
        }else{
            
            x[top] = atoi(s);
            top++;
            }
        
    }
    
    printf("%d\n",x[0]);

    return 0;
}

