
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int pop();
void push(int );
int cal(char );
int top=1;
int stuff[100];
int main(){
  int i=0,num,j;
  char c[100],m;
  while(scanf("%s",c)!=EOF){
    /*if('0'<=c[i] && c[i]<='9'){
      num=c[i]-48;
      push(num);
      }*/
    for(j=0;c[j]!=EOF;j++){
      if(c[j]=='\n'){break;}
    }
    
    if('+'==c[0] || '-'==c[0] || '*'==c[0]){
      push(cal(c[0]));
    }
    else {
      num = atoi(c);
      push(num);
    }
    
  }
  printf("%d\n",stuff[top-1]);

  return 0;
}

void push(int num){
  stuff[top]=num;
  /*printf("%d\n",stuff[top]);*/
  top++;
}

int cal(char kei){
  int n1,n2,ans;
  n2=pop();
  n1=pop();
  if(kei=='+'){
    ans=n1+n2;
  }
  else if(kei=='-'){
    ans=n1-n2;
  }
  else if(kei=='*'){
    ans=n1*n2;
  }
  else {}
  return ans;
}

int pop(){
  top--;
  return stuff[top];
}

