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

int i=1;

int main(){

  int num[100],x,y,result,j;
  char cal[100];

    while(scanf("%cal",cal) != EOF){
      if(cal[0]=='+'){

	x=num[i];
	i--;
	y=num[i];
	result=x+y;
      }
      else if(cal[0]=='-'){

	x=num[i];
	i--;
	y=num[i];
	result=y-x;
      }

      else if(cal[0]=='*'){

	x=num[i];
	i--;
	y=num[i];
	result=x*y;
      }
      else{
	num[i]=atoi(cal);
	i++;
      }
    }

  printf("%d\n",result);

  return 0;
}