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

#define MAX 100
#define NUMBER '0'

void initialize(void);
void push(int);
int pop(void);
int isEmpty(int);
int isFull(int);

int top;

int main(){

  int i,c,s,type;
  int count=0;
  int pop2;
  char S[MAX];

  initialize();
  /*
  for(i=0;i<MAX;i++){
    c = scanf("%c",S[i]);
    count++;
    if(c == EOF)break;
  }

  for(i=0;i<MAX;i++){
    s = atoi(S[i]);
    if(
  }
  */
  
  while((type = getop(S)) != EOF){
      
    pop2 = pop(); //??????push?????????
    
    switch (top) {
    case NUMBER:
      push(atoi(S));
      break;
      
    case '+':
      push(pop() + pop());
      break;
      
    case '*':
      push(pop() * pop());
      break;
      
    case '-':
      push(pop() - pop2);
      break;
      
    case '\n':
      printf("%d\n", pop());
      break;
      
    default:
      printf("error: unknown command %s\n", s);
      break;
    }
  }
  return 0;
}

void initialize(void){
  top = 0;    
}

int val[MAX];

void push(int x){
  if(isFull(top) == 1){
    printf("??¨?????????????????????????????????\n");
    exit(1);
  }
  top++;
  val[top] = x;
}

int pop(void){
  if(isEmpty(top) == 1){
    printf("??¨???????????¢?????????????????????\n");
    return 0;
  }    
  top--;
  return val[top+1];
}

int isEmpty(top){
  if(top == 0) return 1;
  return 0;
}

int isFull(top){
  if(top >= MAX - 1) return 1;
  return 0;
}

#include <ctype.h>

int getch(void);
void ungetch(int);

/* getop:????¬???????????????????????????°???????¢?????????°?????¨??£?????????*/
int getop(char S[])
{
	int i, c;

	while ((S[0]= c = getch()) == ' ' || c == '\t')
		;
	S[1] = '\0';
	if (!isdigit(c) && c != '.')
		return c;	/*???c?????°??§????????? */
	i = 0;
	if (isdigit(c)) /*?????´??°??¨???????????????*/
		while (isdigit(S[++i] = c = getch()))
			;
	if (c == '.') /*????°???°??¨???????????????*/
		while (isdigit(S[++i] = c = getch()))
			;
	S[i] = '\0';
	if (c != EOF)
		ungetch(c);
	return NUMBER;
}

char buf[MAX];
int bufp =0;

int getch(void) /* 1??????????????£????????? */
{
	return (bufp > 0) ? buf[--bufp] : getchar();
}

void ungetch(int c) /* ???????????\???????????? */
{
	if (bufp >= MAX)
		printf("ungetch: too many characters\n");
	else
		buf[bufp++] = c;
}