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

int A[100],n;

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

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

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

    }
  }
  printf("%d\n",pop());
  
  return 0;
}
