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

#define A 1000

void push(int);
int pop(void);

int lead, array[A];

int main(){
  int i, j, k;
  lead = 0;
  char l[A];
  while( scanf("%s", l) != EOF ){
    if ( l[0] == '+' ){
      i = pop();
      j = pop();
      push(i + j);
    } else if ( l[0] == '-' ){
      j = pop();
      i = pop();
      push(i - j);
    } else if ( l[0] == '*' ){
      i = pop();
      j = pop();
      push(i * j);
    } else {
      k = atoi(l);
      push(k);
    }
  }
  
  printf("%d\n", pop());

  
  return 0;
}

int pop(){
  --lead;
  return array[lead+1];
}

void push(int k){
  array[++lead] = k;
}

