#include <stdio.h>
#include <stdlib.h>
#define Max 1000
int top;
int s[Max];
int isEnpty(int);
int isFull(int);
int pop();
void push(int);
void initialize();

int main(){
  char c[Max];
  int num1,num2,ans,x;

  initialize();
  
  while(scanf("%s",c)!=EOF){
    if(c[0] == '+'){
      num2=pop();
      num1=pop();
      ans=num1+num2;
      push(ans);
    }else if(c[0]=='-'){
      num2=pop();
      num1=pop();
      ans=num1-num2;
      push(ans);
    }else if(c[0]=='*'){
      num2=pop();
      num1=pop();
      ans=num1*num2;
      push(ans);
    }else{
      x=atoi(c);
      push(x);
    }
  }

  printf("%d\n",pop());
  
  return 0;
}

int isEnpty(int top){
  if(top==0){
    return 1;
  }else{
    return 0;
  }
}

int isFull(int top){
  if(top > Max){
    return 1;
  }else{
    return 0;
  }
}

void initialize(){
  top = 0;
}

int pop(){
  if(isEnpty(top)==1){
    fprintf(stderr,"stackOfEnpty");
    exit(1);
  }
  top--;
  return s[top+1];
}

void push(int x){
  if(isFull(top)==1){
    fprintf(stderr,"StackOfFull\n");
    exit(1);
  }else{
    top++;
    s[top]=x;
  }
}