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

void push(int);
int pop();

int top = 0,array1[100];
  
int main(){
  char array2[100];
  int n1,n2;

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

int pop(){
  top--;

  return array1[top+1];
}

