#include<stdio.h>
#include<stdlib.h>
#define N 100

int top = 0;
int sep = 0;

typedef struct{
  int num[N];
}a;

int Sum(a, char);

int main(){
  int i, j, sum[N];
  char c[N];
  a S;
  for(i = 0; ; i++){
    scanf("%s",c);
    if(c[0] == 3){
      sep--;
      break;
    }
    if(c[0] == 42 || c[0] == 43 || c[0] == 45){
      sum[sep] = Sum(S, c[0]);
      sep++;
      if(c[1] == 42 || c[1] == 43 || c[1] == 45){
	for(j = 0; j < sep; j++) S.num[j] = sum[j];
	top = sep;
	for(j = 0; j < sep; j++) sum[sep] = Sum(S, c[1]);
	break;
      }
      top = 0;
    }
    else{
      S.num[top] = atoi(c);
      top++;
    }
  }
  printf("%d\n",sum[sep]);
  return 0;
}

int Sum(a S,char c){
  int i, sum = 0;
  switch(c){
  case 42:
    sum = 1;
    for(i = 0; i < top; i++) sum *= S.num[i];
    return sum;
  case 43:
    for(i = 0; i < top; i++) sum += S.num[i];
    return sum;
  case 45:
    sum = S.num[0];
    for(i = 1; i < top; i++) sum -= S.num[i];
    return sum;
  }
}