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

void push(int);
int pop(void);

int top=0;
int a[100];


int main(){
  int x,i=0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x = pop();
      x = x + pop();
      push(x);

    } else if ( s[0] == '-' ){
      x = pop();
      x = pop() - x;
      push(x);

    } else if ( s[0] == '*' ){
      x = pop();
      x = x * pop();
      push(x);
      
    } else {
      x = atoi(s);
      push(x);
      

    }
  }
  printf("%d\n",a[1]);

  return 0;
}

void push(int x){
  if(top>=100){
    exit(1);
  }
  top++;
  a[top] = x;
}

int pop(){
  if(top<=0){
    exit(2);
  }
  top--;
  return a[top+1];
}

