#include<stdio.h>
#include<stdlib.h>
int push(int *s,int x);
int pop(int *s);
static int top=1;
int main(){
  int s[100],st,a,b;
  char c[5];

  while(1){
    scanf("%c",&c[0]);
    if(c[0]=='\n')break;
    if(c[0]<=57 && 48<=c[0])
      push(s,atoi(c));
    else if(c[0]=='+')
      push(s,(pop(s)+pop(s)));
    else if(c[0]=='-'){
      a=pop(s);
      b=pop(s);
      push(s,b-a);
    }
    else if(c[0]=='*')
      push(s,(pop(s)*pop(s)));
  }
  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];
}

