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

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

int top=0;

int main(){
  int s[100],res,ope;
  char c[10];

  while(scanf("%s",c)!=EOF){
    if(c[0]>='0'&&c[0]<='9')push(s,atoi(c));
    else if(c[0]=='+'||c[0]=='-'||c[0]=='*'){
      ope=pop(s);
      res=pop(s);
      if(c[0]=='+')res+=ope;
      else if(c[0]=='-')res-=ope;
      else if(c[0]=='*')res*=ope;
      push(s,res);
    }
  }
  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];
  }
}