#include<stdio.h>
#include<stdlib.h>
int c[199];
int number=0;

void push(int x){
  number++;
  c[number]=x;
}
int pop(){
  number--;
  return c[number+1];
}
  
int main(){
  char s[199];
  int x,y;
  while(scanf("%s",s)!=EOF){
    switch(s[0]){
    case '+':
      push(pop()+pop());
      break;
    case '*':
      push(pop()*pop());
      break;
    case '-':
      y = pop();
      x = pop();
      push(x-y);
      break;
    default:
      push(atoi(s));
      break;
    }
  }
  printf("%d\n",pop());
  return 0;
}

      

