#include<stdio.h>
 #include<stdlib.h>
 #include<string.h>
 
 
 int pop(void);
 void push(int insert);
 
 
int top = 1;
int matrix[2000];

int main(){

  int a,b,x;
  char pre_date;
  while((x = scanf("%s",&pre_date)) != -1){
    if(pre_date == '+') {
      a = pop();
      b = pop();
      push(b+a);

    }
    else if(pre_date == '-'){
     a = pop();
      b = pop();
      push(b-a);

    }
    else if(pre_date == '*'){
      a = pop();
      b = pop();
      push(b*a);

    }


    else push(atoi(&pre_date));

  }

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

  return 0;

}


int pop(void){
  top--;
  //fprintf(stderr,"top %d : return matrix %d\n",top,matrix[top]);
  return matrix[top];

}


void push(int insert){
  //fprintf(stderr,"insert %d\n",insert);
  matrix[top] = insert;
  top++;
}