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

int main(void){


  int top=0,stack[200],i;
  char tmp[7];

  while(scanf("%s",&tmp)!=EOF){

    if(tmp[0] == '+') {
      stack[top-2] = stack[top-2]+stack[top-1];
      top--;
    }   

    else if(tmp[0] == '-') {
      stack[top-2] = stack[top-2]-stack[top-1];
      top--;
    }

    else if(tmp[0] == '*') {      
      stack[top-2] = stack[top-2]*stack[top-1];
      top--;
    }
    
    else { 
      stack[top] = atoi(tmp);
      top++;
    }
   

  }



  printf("%d\n",stack[top-1]);

  return 0;

}