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

int isEmpty();
void push(int*,int);
int pop(int*);

int top=0;

int main(){
  int s[100],t1,t2;
  char c[10];

  while(scanf("%s",c)!=EOF){
    if(c[0]=='+'||c[0]=='-'||c[0]=='*'){
      t1=pop(s);
      t2=pop(s);
      if(c[0]=='+')t2+=t1;
      else if(c[0]=='-')t2-=t1;
      else if(c[0]=='*')t2*=t1;
      push(s,t2);
    }
    else push(s,atoi(c));
  }
  printf("%d\n",pop(s));
  return 0;
}

int isEmpty(){
  if(top==0)return 1;
  else return 0;
}

void push(int* s,int x){
  top++;
  s[top]=x;
}

int pop(int* s){
  if(isEmpty()){
    fprintf(stderr,"underflow\n");
    exit(1);
  }
  else {
    top--;
    return s[top+1];
  }
}