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

void pushStack(int *, int, int *);
void calc(int *, int *, char*);

main(){
  int stack[100];
  int top=0;
  char tmp[1000000];

  while(scanf("%s", tmp) != EOF){
    if(tmp[0] >= '0' && tmp[0] <= '9') pushStack(stack, atoi(tmp), &top);
    else calc(stack, &top, tmp);
  }

  printf("%d\n", stack[1]);

  return 0;
}

void pushStack(int *stack, int tmp, int *top){
  (*top)++;
  stack[*top] = tmp;

  return;
}

void calc(int *stack, int *top, char *enzanshi){
  //オペランンドを２つpop&計算.計算結果をpush
  int res;

  switch(enzanshi[0]){
  case '+':
    res = stack[*top-1] + stack[*top];
    break;
  case '-':
    res = stack[*top-1] - stack[*top];
    break;
  case '*':
    res = stack[*top-1] * stack[*top];
    break;
  }

  *top = *top - 2; //pop2回分
  pushStack(stack, res, top);

  return;
}