#include<stdio.h>

int main(){
  int i=0;
  char s;
  int x[101];

  while(scanf("%c", &s)!= EOF){
    if(s==' ')
      continue;
    else if(s=='+'){
      x[i-2] = x[i-2]+x[i-1];
      i--;
    }else if(s=='-'){
      x[i-2] = x[i-2]-x[i-1];
      i--;
    }else if(s=='*'){
      x[i-2] = x[i-2]*x[i-1];
      i--;
    }else{
      x[i] = s-'0';
      i++;
    }
  }

  printf("%d\n",x[0]);
  return 0;
}