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

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

Stack S;

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

int main(){
  FILE *fp;
  char str[100];
  int a,b;

  fp = fopen("in.txt","w");
  fgets(str,150,stdin);
  fprintf(fp,"%s",str);
  fclose(fp);

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

    else{
      switch(str[0]){
      case '+':
	a = pop();
	b = pop();
	push(a+b);
	break;
	
      case '-':
	a = pop();
	b = pop();
	push(b-a);
	break;
	
      case '*':
	a = pop();
	b = pop();
	push(a*b);
	break;
	
      default:
	break;
      }
    }
  }

  printf("%d\n",pop());

  fclose(fp);
  return 0;
}

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

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

int pop(){
  if(isEmpty()){
    fprintf(stderr,"underflow!!\n");
    exit(8);
  }

  else
    S.top--;
  
  return S.stk[S.top + 1];
}

