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