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

#define N 100

int pr,stack[1000];

void push(int a){
  stack[++pr]=a;
}

int pop(){
  pr--;
  return stack[pr+1];
}

int main(){
  int x,y;
  char ary[N];
  pr=0;
  while(scanf("%s",ary)!=EOF){
    if(ary[0]=='+'){
      x=pop();
      y=pop();
      push(x+y);
    }
    else if(ary[0]=='-'){
      x=pop();
      y=pop();
      push(x-y);
    }
    else if(ary[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }
    else{
      push(atoi(ary));
    }
  }
  printf("%d\n",pop());
  return 0;
}
  

