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

#define N 100

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

int top,S[N];

int main(){
  int x,y;
  top = 0;
  char T[N];
  while(scanf("%s",T) != EOF){
    if(T[0] == '+'){
      x = pop();
      y = pop();
      push(x+y);
    }
    else if(T[0] == '-'){
      x = pop();
      y = pop();
      push(x-y);
    }
    else if(T[0] == '*'){
      x = pop();
      y = pop();
      push(x*y);
    }
    else{
      push(atoi(T));
    }
  }
  printf("%d\n",pop());

  return 0;
}

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

void push(int z){
  S[++top] = z;
}