#include<stdio.h>
#include<stdlib.h>
#define prinf printf

int main(){
  char a[10];
  int stack[100];
  int head=0;

  while(scanf("%s",a)!=EOF){
    if(a[0]=='+'){
      stack[head-2]=stack[head-2]+stack[head-1];
      head--;
    }else if(a[0]=='-'){
      stack[head-2]=stack[head-2]-stack[head-1];
      head--;
    }else if(a[0]=='*'){
      stack[head-2]=stack[head-2]*stack[head-1];
      head--;
    }else{
      stack[head]=atoi(a);
      head++;
    }
  }
  
  prinf("%d\n",stack[0]);
  
  return 0;
}
  