#include <stdio.h>

typedef struct stack
{int num;
    int list[100];
} stack;

stack stack1={0};


void push(stack *a, int n) {

a->list[a->num]=n;
a->num++;

}

int pop(stack *a){
    int x;
    a->num--;
    x=a->list[a->num];

    return x;
}

int main() {
    int i, j = 0, k, n,m,w;
    int flag = 0;
    m=(int)'0';
    while (1) {
        i = getchar();
        switch (i) {
            case '+':
                k = pop(&stack1);
                j = pop(&stack1);
                n = j + k;

                push(&stack1, n);
                break;
            case '-':
                k = pop(&stack1);
                j = pop(&stack1);
                n = j - k;

                push(&stack1, n);
                break;
            case '*':
                k = pop(&stack1);
                j = pop(&stack1);
                n = j * k;

                push(&stack1, n);
                break;
            case ' ':
                break;
            default:
                w= (int) i;
                k=w-m;


                push(&stack1,k);

                break;
            case '\n':
                flag = 1;
                break;
            case 'EOF':
                flag = 1;
                break;


        }
        if (flag == 1)break;

    }
    printf("%d\n",pop(&stack1));
}
