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

typedef struct {
    int sp; // stack pointer
    int s_array[100];
} Stack;

void init_stack(Stack *S){
    S->sp = 0;
}

int is_empty(Stack *S){
    return S->sp == 0;
}

int pop(Stack *S){
    S->sp -= 1;
    return S->s_array[S->sp + 1];
}

void push(Stack *S, int x){
    S->sp += 1;
    S->s_array[S->sp] = x;
}


int main(void){
    Stack S;
    char str[10];
    int x, y;

    // initialize the stack
    init_stack(&S);

    while(scanf("%s", str) != EOF){
        if(str[0] == '+'){
            y = pop(&S);
            x = pop(&S);
            push(&S, x + y);
        }
        else if(str[0] == '-'){
            y = pop(&S);
            x = pop(&S);
            push(&S, x - y);
        }
        else if (str[0] == '*'){
            y = pop(&S);
            x = pop(&S);
            push(&S, x * y);
        }
        else{
            push(&S, atoi(str));
        }
    }
    
    printf("%d\n", pop(&S));

    return 0;
}

