#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define STACKSIZE 1024
int n = 0;
int stack[STACKSIZE];

void push(int x){
  if ( n >= STACKSIZE){
    fprintf(stderr, "stack overflow\n"); exit(1);
    n=0;
  }
  n++;
  stack[n]=x;
}

int pop(){
  if(n == STACKSIZE) fprintf(stderr,"stack underflow\n"); exit(1);
  n--;
  return stack[n+1];
}

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

  while ((c=getchar())!=EOF){
    if (isdigit(c)){
      ungetc(c, stdin);
      scanf("%d", &x);
      push(x);
    }
    else {
      switch(c) {
      case '+':
	b=pop();
	a=pop();
	push(a+b);
	break;
      case '-':
	b=pop();
	a=pop();
	push(a-b);
	break;
      case '*':
	b=pop();
	a=pop();
	push(a*b);
	break;
      case '/':
	b=pop();
	a=pop();
	push(a/b);
	break;
      case '\n':
	if (n==1){
	  printf("The answer is %d.\n", pop());
	}
	else {
	  printf("Invalid expression.\n");
	  n=0;
	}
      case ' ':
	break;
      case '\t':
	break;
      default:
	printf("Invalid input.\n");
	n=0;
	break;
      }
    }
  }
}

