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

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

      

