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

int top,A[1000];


void push(int a){
  
  top++;
  A[top] = a;
}

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

int main(){
  int a,b;
  top = 0;
  char B[100];
  while(scanf("%s",B) !=EOF){
    if(B[0] == '+') {
      a = pop();
      b = pop();
      push(a+b);
    }
    else if(B[0] == '-'){
      b = pop();
      a = pop();
      push(a-b);
    }
    else if(B[0]=='*'){
      a = pop();
      b = pop();
      push(a*b);
    }
    
    else{
      push(atoi(B));
    }
  }
  printf("%d\n",pop());

  return 0;
}
