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

int main(void){
  
  int t,top=0,x[100];
  char a[100];
  
  while( scanf("%s",a) != EOF ){
    
    if(a[0] == '+'){
      x[top-1] = x[top-2] + x[top-1];
      top--;
    }
    
    else if(a[0] == '-'){
      x[top-1] = x[top-2] - x[top-1];
      top--;
    }
    
    else if(a[0] == '*'){
      x[top-1] = x[top-2] * x[top-1];
      top--;
    }

    else{
      t = atoi(a);
      x[top]=t;
      top++;
    }

  }
    printf("%d\n",x[top-2]);
      return 0;


}