#include <stdio.h>
#include <string.h>
int main(){
  char buf[1200];
  char tmp[8];
  int stk[100];
  int len;
  int i, j, k = 0;
  int P_s;
  while(1){
    gets(buf);
    len = 0;
    for(i = 0; i < 200 & (P_s = sscanf(buf + len, "%s", tmp)) != 0 & P_s != EOF; i++){
      len += strlen(tmp) + 1;
      stk[k] = 0;
      if(k < 100 & tmp[0] >= '0' & tmp[0] <= '9'){
	for(j = 0; j < strlen(tmp); j++){
	  stk[k] *= 10;
	  stk[k] += tmp[j] - '0';
	}
	k++;
      }
      else{
	if(k > 0 & (tmp[0] == '+' | tmp[0] == '-' | tmp[0] == '*')){
	  k--;
	  switch(tmp[0]){
            case '+':
	      stk[k - 1] += stk[k];
	      stk[k] = 0;
	      break;
            case '-':
	      stk[k - 1] -= stk[k];
	      stk[k] = 0;
	      break;
            case '*':
	      stk[k - 1] *= stk[k];
	      stk[k] = 0;
	      break;
            default:
	      stk[k];
	      break;
	  }
	}
      }
      for(j = 0; j < strlen(tmp); j++)
	tmp[j] = '\0';
    }
    if(strlen(buf) < 256)
      break;
  }
  printf("%d\n", stk[0]);
  return 0;
}