#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int x[100],i=0,p=0;
  char s[100];

  while( scanf("%s",s) != EOF){
    if ( s[0] == '+' ){
      x[p-1]=x[p-1] + x[p];
      p--;
      
    } else if ( s[0] == '-' ){
      x[p-1]=x[p-1] - x[p];
      p--;
    } else if ( s[0] == '*' ){
      x[p-1]=x[p-1] * x[p];
      p--;
    } else {
      p++;
      x[p] = atoi(s);
      
    }
  }
  printf("%d\n",x[p]);
  return 0;
}