#include<stdio.h>
#include<stdlib.h>
#define STACKSIZE 100

typedef struct {
  int items[STACKSIZE];
  int top;
} Stack;

void init( Stack *s);
void push( Stack *s, int i);
int pop( Stack *s);

int main(void)
{
  char s[11];
  int x, y;
  Stack stack;

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

  printf("%d\n", pop(&stack));
  return 0;
}

void init( Stack *s) { s->top = 0;}
void push( Stack *s, int i) { s->items[s->top++] = i;}
int pop( Stack *s) { return s->items[--s->top];}

