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

int main(void){
  int x[101],i=0;
  char s[101];

  while( scanf("%s",s) != EOF ){
    if ( s[0] == '+' ){
    	i--;
    	x[i] = x[i] + x[i+1];

    } else if ( s[0] == '-' ){
    	i--;
    	x[i] = x[i] - x[i+1];

    } else if ( s[0] == '*' ){
    	i--;
    	x[i] = x[i] * x[i+1];

    } else {
    	i++;
      x[i] = atoi(s);

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

  return 0;
}
