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

int top, S[1000];

void push(int x)
{
    S[++top] = x;
}

int pop()
{
    top--;
    return S[top + 1];
}

int main()
{
    int a, b;
    top = 0;

    char s[100];

    while (scanf("%s", s) != EOF)
    {
        char str = s[0];
        if (str == '+' || str == '-' || str == '*')
        {
            int right = pop();
            int left = pop();
            if (str == '+')
            {
                push(right + left);
            }
            else if (str == '-')
            {
                push(left - right);
            }
            else if (str == '*')
            {
                push(right * left);
            }
        }
        else
        {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
}
