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

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

int top=0;
int S[100];

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

return 0;
}

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

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

