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

int stack[100];
int top = 0;

int push(int n) {
    stack[top] = n;
    top++;
    return 0;
}

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



int main(void) {
    char x;
    int y, tmp;

    while (scanf("%s", &x) == 1) {
        y = atoi(&x);
        if (y == 0) {
            tmp = pop();
            switch (x) {
            case '+':
                push(pop()+tmp);
                break;
            case '-':
                push(pop()-tmp);
                break;
            case '*':
                push(pop()*tmp);
            default:
                break;
            }
        } else {
            push(y);
        }
    }
    printf("%d\n", pop());

    return 0;
}
