#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define SIZE 200

struct stack{
    int top;
    int elem[SIZE];
};

void initstack(struct stack *p){
    p->top=-1;
}

int stackempty(struct stack *p){
    return p->top<0;
}

int pop(struct stack *p){
    int val;
    if(p->top<0){
        printf("Underflow.\n");
        exit(1);
    }else{
        val=p->elem[p->top];
        p->top--;
        return val;
    }
}

void push(struct stack *p,int val){
    p->top++;
    if(p->top>=SIZE){
        printf("Overflow.\n");
        exit(1);
    }else{
        p->elem[p->top]=val;
    }
    return;
}

int main(void){
    struct stack s;
    char buf[200];
    int a,b;
    
    initstack(&s);
    
    while(scanf("%s",buf)!=EOF){
        if(buf[0]=='+'){
            a=pop(&s);
            b=pop(&s);
            push(&s,a+b);
        }
        else if(buf[0]=='-'){
            a=pop(&s);
            b=pop(&s);
            push(&s,a-b);
        }
        else if(buf[0]=='*'){
            a=pop(&s);
            b=pop(&s);
            push(&s,a*b);
        }else{
            push(&s,atoi(buf));
        }
    }
    
    printf("%d\n",pop(&s));
    return 0;
}