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

int stack[1000];
int top = 0, bottom = 0;

void push(int value) {
    stack[++top] = value;
}

int pop(void) {
    return stack[top--];
}


int main() {
    char str[100];
    while (scanf("%s", str) != EOF) {
        switch (str[0]) {
            case '-': {
                int v1 = pop();
                int v2 = pop();
                push(v2 - v1);
                break;
            }
            case '+': {
                push(pop() + pop());
                break;
            }
            case '*': {
                push(pop() * pop());
                break;
            }
            default: {
                push(atoi(str));
                break;
            }
        }
    }
    printf("%d\n", pop());
    return 0;
}