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

#define ST_MAX 100

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

int stack[ST_MAX];
int top = 0;

int main(void){
  int x,temp1,temp2;
  char S[ST_MAX];
  while( scanf("%s", S) != EOF ){
    if ( S[0] == '+'){
      temp1 = pop();
      temp2 = pop();
      x = temp1 + temp2;
      //printf("%d",x);
      push(x);

    } else if ( S[0] == '-' ){
      temp1 = pop();
      temp2 = pop();
      x = temp2 - temp1;
      //printf("%d",x);
      push(x);

    } else if ( S[0] == '*' ){
      temp1 = pop();
      temp2 = pop();
      x = temp1 * temp2;
      /* printf("%d",x); */
      push(x);

    } else {
      x = atoi(S);
      push(x);
    }
  }

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

void push(int x){
  top++;
  stack[top] = x;
}

int pop(void){
  top--;
  return stack[top + 1];
}

