#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(){
  int x;
  char s[200];
  signed long long stack[200];
  int esp = 0;
 
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      esp--;
      stack[esp - 1] += stack[esp];
    } else if ( s[0] == '-' ){
      esp--;
      stack[esp - 1] -= stack[esp];
    } else if ( s[0] == '*' ){
      esp--;
      stack[esp - 1] *= stack[esp];
    } else {
      x = atoi(s);
      stack[esp] = x;
      esp++;
    }
  }
 
  printf("%lld\n", stack[0]);
 
  return 0;
}
