#include <stdio.h>

#define MAX 100

void push(int);
long pop();

int S[MAX];
int top=0;

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 (top==1){
	  printf("%d\n", pop());
	}
	else {
	  printf("Invalid expression.\n");
	  top=0;
	}
      case ' ':
	break;
      case '\t':
	break;
      default:
	printf("Invalid input.\n");
	top=0;
	break;
      }
    }
  }
}

void push(int x)
{
        if ( top >= MAX){
                fprintf(stderr, "stack overflow\n");
                top=0;
        }
        top++;
        S[top]=x;
}
long pop()

{
	top--;
	return S[top+1];

}