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

#define N 10
#define MAX 101

int top;
int S[MAX];

void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

int main(void){
  char A[N];
  int x=0,a,b;
  int i;

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

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

void initialize(void){
  top = 0;
}

int isEmpty(void){
  return top == 0;
}

int isFull(void){
  return top >= MAX - 1;
}

void push(int x){
  if(isFull()){
    fprintf(stderr,"stuck is full\n");
  }
  else{
    top++;
    S[top] = x;
  }
}

int pop(void){
  if(isEmpty()){
    fprintf(stderr,"stuck is empty\n");
    return 0;
  }
  else{
    top--;
    return S[top+1];
  }
}

