#include <stdio.h>
#include <limits.h>

int stack[1000];
int top;

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

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

int main()
{
#ifdef TEST
    freopen("input", "r", stdin);
#endif

    char s[5];
    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            int a = pop();
            int b = pop();
            push(a + b);
        } else if (s[0] == '-') {
            int a = pop();
            int b = pop();
            push(b - a);
        } else if (s[0] == '*') {
            int a = pop();
            int b = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }
    }

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

    return 0;
}

