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

#define N 100

int top,stack[N];

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

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

int main(){
  int x,y;
  char s[100];

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

  

