#include <stdio.h>
#include <stdlib.h> //atoi関数
void push(int);
int pop();
int isEmpty();

int S[100],top;

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

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

int pop(){
  if(isEmpty()){
    fprintf(stderr,"error:isEmpty\n");
    exit(1);
  }
  else {
    top = top - 1;
  }
  return S[top+1];
}

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

