#include <stdio.h>
#include <math.h>
#define N 100

int i=0;
int e[N];
void hairetu(int);

int main(){

  char k[100];

  while( scanf("%s",k)!=EOF){

    if(k[0]=='+'){
      i--;
      e[i]=e[i]+e[i+1];
    }
    else if(k[0]=='*'){
      i--;
      e[i]=e[i]*e[i+1];
    }
    else if(k[0]=='-'){
      i--;
      e[i]=e[i]-e[i+1];
    }
    else{
      hairetu(atoi(&k));
    }
  }
  printf("%d\n" ,e[i]);
  return 0;
}

void hairetu(int k){
  i++;
  e[i]=k;
}
  
  

