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

int top = 0, a[100];

void push(int);
int pop(void);

int main(){
    int x, temp, r, l;
    char s[100];
    
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            temp = pop() + pop();
            push(temp);
        }
        
        else if(s[0] == '-'){
            r = pop();
            l = pop();
            temp = l - r;
            push(temp);
        }
        
        else if(s[0] == '*'){
            temp = pop() * pop();
            push(temp);
        }
        
        else{
            x = atoi(s);
            
            push(x);
        }
    }
    printf("%d\n", a[1]);
    
    return 0;
}


void push(int x){
    top++;
    a[top] = x;
}

int pop(){
    top--;
    return a[top + 1];
}
