#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int push(int *s,int x);
int pop(int *s);
static int top=1;
int main(){
  int s[100],a,b,c,st;
  char bash[100];
  
  while(st=(scanf(" %s",bash))!=EOF){

    /* if(bash[0]=='\n')break; */

    if(bash[0]=='+')
      push(s,(pop(s)+pop(s)));
    else if(bash[0]=='-'){
      a=pop(s);
      b=pop(s);
      push(s,b-a);
    }
    else if(bash[0]=='*')
      push(s,(pop(s)*pop(s)));
    else
      
      push(s,atoi(bash));
  }
  printf("%d\n",pop(s));
  return 0;
}
int push(int *s,int x){
  top=top+1;
  s[top]=x;
}
int pop(int *s){
  top=top-1;

  return s[top+1];
}


