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

typedef struct{
  int array[100];
  int current;
}STACK;

void push (STACK*, int);
int pop (STACK*);

int main () {

  int x,a,b;
  char op[100];
  STACK num;
  num.current = 0;

  while(scanf("%s",op) != EOF){
    if( op[0] == '+'){
       a = pop(&num);
       b = pop(&num);
       push(&num, a+b);
    }
    else if( op[0] == '-'){
       a = pop(&num);
       b = pop(&num);
       push(&num, b-a);
    }
    else if( op[0] == '*'){
       a = pop(&num);
       b = pop(&num);
       push(&num, a*b);
    }
    else {
      x = atoi(op);
      push(&num,x); 
    }
  }

  printf("%d\n",num.array[1]);

return 0;
}

void push (STACK* s, int x){
  s->current++;
  s->array[s->current] = x;
}

int pop (STACK* s){
  s->current = s->current - 1;
  return s->array[s->current+1];
}