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

int main(){
  int x,a[100],i=0;
  char s[100];
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a[i-2]+=a[i-1];
      i--;
    } else if ( s[0] == '-' ){
      a[i-2]-=a[i-1];
      i--;
    } else if ( s[0] == '*' ){      
      a[i-2]*=a[i-1];
      i--;
    }
    else {
      x = atoi(s);
      a[i]=x;
      i++;
    }
  }
  printf("%d\n",a[0]);
  return 0;
}