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

#define MAX 101

void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

int top;
int S[MAX];
int main(){
  char s[300];
  int num=0,b=0,c=0,d=0;
  initialize();
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      b=pop();
      c=pop();
      d=c+b;
      push(d);
    }
    else if(s[0]=='-'){
      b=pop();
      c=pop();
      d=c-b;
      push(d);
    }
    else if(s[0]=='*'){
      b=pop();
      c=pop();
      d=c*b;
      push(d);
    }
    else{
      num=atoi(&s[0]);
      push(num);
    }
  }
  printf("%d\n",S[top]);
  
  return 0;
}

void initialize(void){
  top = 0;
}

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

int isFull(void){
  if(top >= MAX-1){
    return 1;
  }
  else return 0;
}

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

int pop(void){
  if(isEmpty()==1){
    fprintf(stderr,"Under\n");
  }
  else{
    top--;
    return S[top+1];
  }
}

