#include<stdio.h>

int main() {
    char s[10];
    int num[110];
    int tail = 0;
    int a, b, tmp;
    int i;

    while(scanf("%s", s) != EOF) {
        if (s[0] == '+' || s[0] == '-' || s[0] == '*') {
            tail--;
            b = num[tail];
            tail--;
            a = num[tail];
            if (s[0] == '+') a = a + b;
            else if (s[0] == '-') a = a - b;
            else if (s[0] == '*') a = a * b;
            num[tail] = a;
            tail++;
        } else {
            tmp = s[0] - '0';
            i = 1;
            while(s[i] != '\0') {
                tmp *= 10;
                tmp += (s[i] - '0');
                i++;
            }
            num[tail] = tmp;
            tail++;
        }
    }

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