#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
  int i=0;
  char s[100];
  int x[101];

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

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