#include <stdio.h>
#define X 100
#define Y 100
int axis[X],size=0;
int theO(){
  if(size<=0) return 0;
  return axis[--size];
}
int hyakushiki(int a){
  axis[size++]=a;
  return 0;
}
int expert(char *jojo){
  if(*jojo=='+'||*jojo=='-'){
    jojo++;
    if (*jojo>='0'&&*jojo<='9') return 1;
    return 0;
  }
  if(*jojo>='0'&&*jojo<='9') return 1;
  return 0;
}
int Zgundam(char *lim){
  int Z=0,n=0;
  if(*lim=='+')lim++;
  else if(*lim=='-'){
    Z=1;
    lim++;
  }
  while(*lim>='0'&&*lim<='9'){
    n=n*10+(*lim-'0');
    lim++;
  }
  if(Z)return -n;
  return n;
}
int gundam_mk2(char *A){
  int x1,x2,n;
  while(*A){
    if (expert(A)){
      n=Zgundam(A);
      hyakushiki(n);
      while(*A=='-'||*A=='+'){
	A++;
      }
      while(n){
	n/=10;
	A++;
      }
    }
    else{
      switch(*A){
      case '+':x1=theO();
	x2=theO();
	hyakushiki(x1+x2);
	break;
      case '-':x1=theO();
	x2=theO();
	hyakushiki(x2-x1);
	break;
      case '*':x1=theO();
	x2=theO();
	hyakushiki(x2*x1);
	break;
      }
      A++;
    }
  }
  return theO();
}
int main(){
  char array[Y];
  scanf("%[^\n]*s", array);
  printf("%d\n",gundam_mk2(array));
}

