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

#define MAX_NUM_STACK_VALUES 100
#define STR_MAX_LENGTH 100

/*
 * Stack
 */

typedef struct {
    int top; // index of top
    int values[MAX_NUM_STACK_VALUES];
} Stack;

void printStack(Stack S) {
    for (int i = 1; i <= S.top; i++)
        printf("%d ", S.values[i]);
    printf("\n");
};

void push(Stack * p_stack, int value) {
    p_stack->top = p_stack->top + 1;
    p_stack->values[p_stack->top] = value;
};

int isEmpty(Stack stack) {
    return (stack.top == 0);
};

int pop(Stack * p_stack) {
    if (!isEmpty(*p_stack))
        p_stack->top = p_stack->top - 1;
    
    return p_stack->values[p_stack->top + 1];
};




int main(int argc, char** argv) {
    // init Stack
    Stack S;
    S.top = 0;
    
    // char
    char str[STR_MAX_LENGTH];
    int value, a, b;
    
    while (scanf("%s ", &str) != EOF) {
//        printf("scanned:%s\n",str);
        switch(str[0]) {
            case '+':
                b = pop(&S);
                a = pop(&S);
                value = a + b;
//                printf("%d+%d=%d\n",a,b,value);
                break;
            case '-':
                b = pop(&S);
                a = pop(&S);
                value = a - b;
//                printf("%d-%d=%d\n",a,b,value);
                break;
            case '*':
                b = pop(&S);
                a = pop(&S);
                value = a * b;
//                printf("%d*%d=%d\n",a,b,value);
                break;
            default:
                value = atoi(str);
        }
        push(&S, value);
//        printStack(S);
    }
    printf("%d\n", pop(&S));
    

    return (EXIT_SUCCESS);
}


