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

#define N 200
#define C 10000

int s[N], sp;

int pop();
void push(int);

int main(){

  int i;
  int count = 0, n = 0;
  char in[N][C];
  int out;

  i = 0;
  while(scanf("%s", in[i]) != EOF){
    
    count++;
    i++;
  }
  
  for(i = 0; i < count; i++){
    
    
    
    if(in[i][0] == '+'){

      out = pop() + pop();
      push(out);
      
    }
    
    else if(in[i][0] == '-'){

      out = pop() - pop();
      push(out);

    }
    
    else if(in[i][0] == '*'){
      out = pop() * pop();
      push(out);

    }
    else {
      push(atoi(in[i]));
    }

  }
  
  printf("%d\n", out);

  return 0;
}

int pop(){

  sp++;

  return s[sp];
}


void push(int d){

  s[sp] = d;

  sp--;

}