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

#define TRUE 1
#define FALSE 0

typedef struct{
  int stk[100];
  int *top;
}Stack;

int isEmpty(Stack );
void push(Stack *, int);
int pop(Stack *);

int main(){
  FILE *fp;
  Stack S;
  char str[100];
  char opr;
  int a,b;
  int i=0;

  S.top = S.stk;
  
  fp = fopen("in.txt","w");
  scanf("%[^\n]",str);
  fprintf(fp,"%s\n",str);
  fclose(fp);

  fp = fopen("in.txt","r");
  
  while(fscanf(fp,"%s",str)!=EOF){
    if(atoi(str)!=0){
      push(&S, atoi(str));
    }

    else{
      opr = str[0];

      switch(opr){
      case '+':
	a = pop(&S);
	b = pop(&S);
	push(&S, a+b);
	break;

      case '-':
        a = pop(&S);
	b = pop(&S);
	push(&S,b-a);
	break;

      case '*':
	a = pop(&S);
	b = pop(&S);
	push(&S, a*b);
	break;

      default:
	break;
      }
    }
  }
  
  printf("%d\n",pop(&S));
  
  return 0;
}

int isEmpty(Stack S){
  if(S.top == 0)
    return TRUE;

  else
    return FALSE;
}

void push(Stack *S, int x){
  S->top = S->top + 1;
  *(S->top) = x;
}

int pop(Stack *S){
  if(isEmpty(*S))
    fprintf(stderr,"underflow!!\n");

  else
    S->top = S->top - 1;

  return *(S->top + 1);
}

