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

int top,new_num[MAX];
int isEmpty(void){
return top==0;
}
int isFUll(){
	return top >=MAX -1;
}


void push(int x){
	if(isFUll()){
		printf("overflow\n");
		exit(1);
	}
	top++;
	new_num[top]=x;
}
int pop(){
	if(isEmpty()){
		printf("underflow");
		exit(1);
	}
	top--;
	return new_num[top+1];
}
int main(void){
	int x,y,X;
	char num[MAX];

	top=0;
	while(scanf("%s",num) != EOF){
		if(num[0] == '+'){
			x=pop();
			y=pop();
			push(x+y);
		}
		else if(num[0] == '-'){
			x=pop();
			y=pop();
			push(y-x);
		}
		else if(num[0] == '*'){
			x=pop();
			y=pop();
			push(x*y);
		}
		else{
			X=atoi(num);
			push(X);
		}
	}
	printf("%d\n",pop());
	return 0;
}

