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

int main(void)
{
    char s[128];
    int stack[128];
    int size;
    int a, b;
    int tmp;

    size = 0;
    while (scanf("%s", s) != EOF){
        if (isdigit(s[0])){
            tmp = atoi(s);
        }
        else {
            b = stack[size - 1];
            a = stack[size - 2];
            size -= 2;
            switch (s[0]){
                case '+': tmp = a + b; break;
                case '-': tmp = a - b; break;
                case '*': tmp = a * b; break;
            }
        }
        stack[size] = tmp;
        size++;
    }

    printf("%d\n", stack[0]);

    return (0);
}