#include <stdio.h>//我们从下表为1的开始
#include <stdlib.h>
int top,stack[500]={0};
void Initial(void)
{
    top=0;
}

int IsEmpty(void)
{
    return top==0;
}
int IsFull(void)
{
    return top>500;
}
void push(int x)
{
    if(IsFull())printf("UP OVERFLOW");
    top++;
    stack[top]=x;
}
int pop()
{
    if(IsEmpty())printf("LOW OVERFLOW");
    top--;
    return stack[top+1];
}
#if 0
int main() {
    int a, b;
    char ch = '0' ;
    scanf("%c",&ch);
    Initial();
    while (ch != '\n') {
        if (ch == '+') {
            a = pop();
            b = pop();
            push(a + b);
        } else if (ch == '-') {
            a = pop();
            b = pop();
            push(a - b);
        } else if (ch == '*') {
            a = pop();
            b = pop();
            push(a * b);
        } else if (ch != ' ')
            push(ch - '0');
        scanf("%c",&ch);
//        printf("%d\n",pop());
        printf("%d\n",stack[top]);

    }
    printf("%d\n",pop());
    return 0;
}

#elif 1
int main()
{
    char s[100];
    int a,b;
    Initial();
    while(scanf("%s",s)!=EOF)
    {
        if(s[0]=='+')
        {
            a=pop();
            b=pop();
            push(a+b);
        }
        else if (s[0]=='-')
        {
            b=pop();
            a=pop();
            push(a-b);
        }
        else if (s[0]=='*')
        {
            a=pop();
            b=pop();
            push(a*b);
        }
        else push(atoi(s));
    }
    printf("%d\n",pop());
    return 0;
}
#endif
