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

int top;
int C[2];

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

int main(){
  int a,b,x,n;
  char s[100];
  
  while(1){
    n = scanf("%s",s);
    if(n == EOF)break;
    switch(s[0]){     
    case '+':
      a = pop();
      b = pop();
      push(b+a);
      break;
       
    case '-':   
      a = pop();
      b = pop();
      push(b-a);
      break;
       
    case '*':
      a = pop();
      b = pop();
      push(b*a);
      break;
       
    default:
      x = atoi(s);
      push(x);
      break;
    }

  }
  x = pop();
  printf("%d\n",x);

  return 0;
}

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

void push(int x){
  top++;
  C[top]=x;
}
  