#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,S[100];
void push(int x){
  top++;
  S[top]=x;
}
int pop(){
  top--;
  return S[top+1];
}
int main(){
  int catch[2],i=0;
  char c[100];
  top=0;
  while(1){
    if(scanf("%s",c)==EOF)break;
    if(c[0]=='+'){
      catch[0]=pop();
      catch[1]=pop();
      push(catch[0]+catch[1]);
    }
    else if(c[0]=='-'){
       catch[0]=pop();
      catch[1]=pop();
      push(catch[0]-catch[1]);
    }
    else if(c[0]=='*'){
       catch[0]=pop();
      catch[1]=pop();
      push(catch[0]*catch[1]);
    }
    else{
      push(atoi(c));
    }
  }
  printf("%d\n",pop());   



}

