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

#define NMAX 100
#define AMAX 99

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

int top=0;
int bufp[500];

int main(){
  int num,n1,n2;
  char buf[NMAX];
  
  while(scanf("%s",buf)!=EOF){
    if ( buf[0] == '+' ){
      n1=pop();
      n2=pop();
      push(n1+n2);
    } else if ( buf[0] == '-' ){
      n1=pop();
      n2=pop();
      push(n2-n1);
    } else if ( buf[0] == '*' ){
      n1=pop();
      n2=pop();
      push(n1*n2);
    } else {
      num = atoi(buf);
      push(num);
    }
  }
  printf("%d\n",pop());
  return 0;
}

void push(int n){
  top+=1;
  bufp[top]=n;
}

int pop(void){
  top-=1;
  return bufp[top+1];
}



