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

