#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define OPR 100
#define ENZ 99

int stack[OPR+ENZ],pointer;

void push(int op){
  stack[++pointer]=op;
}
int pop(void){
  pointer--;
  return stack[pointer+1];
}

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

