#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 1000

int top, S[MAX];

int isEmpty(){
    return top==0;
}

int isFull(){
    return top>=MAX-1;
}

void push(int x){
    if(isFull()){
        puts("overflow");
        return;
    }
    S[++top] = x;
}

int pop(){
    if(isEmpty()){
        puts("underflow");
        return 0;
    }
    top--;
    return S[top+1];
}
int main(void){
    int a, b;
    char s[100];
    top=0;
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a=pop();
            b=pop();
            push(a+b);
        }else if(s[0] == '-'){
            a=pop();
            b=pop();
            push(b-a);
        }else if(s[0] == '*'){
            a=pop();
            b=pop();
            push(a*b);
        }else{
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
    return 0;
}
