#include<stdio.h>
#include<stdlib.h>
void push(int);
int pop(void);
int s[100];
int top=0;
int main(){
  int ch,x,y;
  char *c;
  while(scanf("%s",c)!=EOF){
    if('0'<=c[0] && c[0]<='9'){
      ch=atoi(c);
      push(ch);
      continue;
    }
    y=pop();
    x=pop();
    if(c[0]=='+')push(x+y);
    else if(c[0]=='-')push(x-y);
    else if(c[0]=='*')push(x*y);
  }
  printf("%d\n",pop());
  return 0;
}

void push(int x){
  s[top++]=x;
}

int pop(){
  return s[--top];
}

