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

#define N 100


int pop(void);
void push(int);
int pointer=0;
int stack[N];

int main(){
  int x=0;
  int y=0;
  int n;
  char s[N];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      x=pop();
      y=pop();
      push(x+y);
    }
    else if (s[0]=='-'){
      x=pop();
      y=pop();
      push(y-x);
    }
    else if(s[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }
    else {
      n=atoi(s);
      push(n);
    }
  }
  printf("%d\n",pop());
  return 0;
}

int pop(){
  pointer--;
  return stack[pointer];
}

void push(int s){
  pointer++;
  stack[pointer-1]=s;
}

