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

#define N 100

int stack[N];
int sp = 0;

void push(int a) {
    stack[sp] = a;
    sp++;
}

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

int main() {
    int ans, a;
    char s[7];
    
    while(scanf("%s", s) != EOF) {
        if ('0' <= s[0] && s[0] <= '9') {
            push(atoi(s));
        } else {
            if (s[0] == '+') {
                ans = pop() + pop();
            }
            if (s[0] == '-') {
                a = pop();
                ans = pop() - a;
            }
            if (s[0] == '*') {
                ans = pop() * pop();
            }
            push(ans);
        }
    }
    printf("%d\n", pop());
    return 0;
}


