#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void push(int);
int pop(void);
int head,st[1000];

int main(){
  int a,b;
  head=0;
  char s[100];

  while(scanf("%s",s)!=EOF){
  
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
      //printf("%d\n",st[head]);
    }else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
      //printf("%d\n",st[head]);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
      //printf("%d\n",st[head]);
    }else{
      push(atoi(s));
      //printf("%d\n",st[head]);
    }
  }
  printf("%d\n",pop());
  return 0;
}
int pop(void){
  head--;
  return st[head+1];
}
void push(int d){
  st[++head]=d;
}

