#include<stdio.h>
int main() {
    char s[100];
    int S[1000];
    int a,b,i,temp,top=0;
    while(scanf("%s", s) != EOF) {
        if (s[0] == '+' || s[0] == '-' || s[0] == '*') {
            top--;
            b = S[top];
            top--;
            a = S[top];
            if (s[0] == '+') a = a + b;
            else if (s[0] == '-') a = a - b;
            else if (s[0] == '*') a = a * b;
            S[top] = a;
            top++;
        }
         else {
            temp = s[0] - '0';
            i = 1;
            while(s[i] != '\0') {
                temp *= 10;
                temp += (s[i] - '0');
                i++;
            }
            S[top] = temp;
            top++;
        }
    }

    printf("%d\n", S[0]);
    return 0;
}

