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

#define TRUE 1
#define FALSE 0
#define N 100
#define MAX 1000000000

int top = 0;
int s[N];
char S[MAX];

int isEmpty(){
	if(top == 0) return TRUE;
	else return FALSE;
}

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

int pop(){
	if(isEmpty() == TRUE) printf("underflow\n");
	else top--;
	return S[top + 1];
}



int main(){
	int x,a,b;

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