#include <stdio.h>
#include <stdlib.h>
int top=0;
int S[1000];
void push(int a){
  S[++top]=a;
}
int pop(){
  top--;
  return S[top+1];
}
int isEmpty(char *a);
int isFull(char *a);
int main(){
  char a[100];
  int len,aa,b;
  while(scanf("%s",a)!=EOF){
    if(a[0] == '+'){
      aa=pop();
      b=pop();
      push(aa+b);
    }
    else if(a[0]== '-'){
      b=pop();
      aa=pop();
      push(aa-b);
    }
    else if(a[0] == '*'){
      aa=pop();
      b=pop();
      push(aa*b);
    }
    else {
      push(atoi(a));
    }
  }
printf("%d\n",pop());
return 0;
}