#include <stdio.h>

int main(){
  int i, j, flag=0, Ans[199];
  char fx[199];
  for(i=0,j=0; i<199; i++){
    scanf("%c",&fx[i]);
    if(fx[i] == '\n') break;
    if(fx[i] >= '0' && fx[i] <= '9'){
      if(flag)
	Ans[j] = Ans[j-1] * 10 + (fx[i]-48);
      else Ans[j] = fx[i] - 48;
      flag = 1;
    }
    else if(fx[i] == '+'){
      Ans[j-2] += Ans[j-1];
      flag = 0;
      j--;
    }
    else if(fx[i] == '-'){
      Ans[j-2] -= Ans[j-1];
      flag = 0;
      j--;
    }
    else if(fx[i] == '*'){
      Ans[j-2] *= Ans[j-1];
      flag = 0;
      j--;
    }
    else if(fx[i] == ' ' && flag){
      j++;
      flag = 0;
    }
    else continue;
  }
    printf("%d\n",Ans[0]);
}