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

