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

int top, s[1000];

void push(int x){
  top++;
  s[top]=x;
}

int pop(){
  top--;
  return s[top+1];
}

int main(){
  int x,y;
  top=0;
  char t[100];

  while(scanf("%s",t)!=EOF){
    if(t[0]=='+'){
      x=pop();
      y=pop();
      push(x+y);
    }
    else if(t[0]=='-'){
      y=pop();
      x=pop();
      push(x-y);
    }
    else if(t[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }
    else push(atoi(t));
  }

  printf("%d\n",pop());

  return 0;
}

