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

int stack[500];
int idx = 0;

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

void push(int n) {
    stack[idx++] = n;
}

int main (void) {
    int n, a, b;
    char s[100];

    while (scanf("%s", s) != EOF) {

        switch (s[0]) {
            case '+':
                a = pop();
                b = pop();
                push(a + b);
                break;
            case '-':
                a = pop();
                b = pop();
                push(b - a);
                break;
            case '*':
                a = pop();
                b = pop();
                push(a * b);
                break;
            default:
                push(atoi(s));
                break;
        }
    }

    printf("%d\n", pop());

    return 0;
}