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

int main() {
  int i=0, x[101];
  char s[100];
 
  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;
}

