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

int main(){
  int i,op[100],t=0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      op[t-2]=op[t-2]+op[t-1];
      t--;
    }
    else if ( s[0] == '-' ){
      op[t-2]=op[t-2]-op[t-1];
      t--;
    }
    else if ( s[0] == '*' ){
      op[t-2]=op[t-2]*op[t-1];
      t--;
    }
    else op[t++] = atoi(s);
    
  }
  printf("%d\n",op[0]);

  return 0;
}


