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

int ope[101];
char com[100];
int top = 0;

void push(int x) {
  top++;
  ope[top] = x;  
 
}


int pop() {
  top--;
  return ope[top+1];
  
}

  
  

  
int main() {
  int a,b = 0;
  int result;
  int c;
  int d,e;
  
  while(scanf("%s",com) != EOF) {
    
    if(com[0] == '+'){ 
      push(pop() + pop());
    }
    else if(com[0] == '-'){
      d = pop();
      e = pop();
      push(e - d);
    } else if(com[0] == '*') {
      push(pop() * pop());
    }	else {
      push(atoi(com));
    }
    
  }

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

  return 0;
  
}