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

void push();
int pop();

int s1[100];
int top=0;

int main(){
  int x,out1,out2,sum;
  char s[100];


  while(scanf("%s",s)!=EOF){



    if ( s[0]== '+' ){
      out1=pop();
      out2=pop();
      push(out1+out2);
    }
    else if ( s[0]== '-' ){
      out1=pop();
      out2=pop();
      push(out2-out1);
    }
    else if ( s[0]== '*' ){
      out1=pop();
      out2=pop();
      push(out1*out2);
    }
    else {
     x = atoi(s);
     push(x);
    }
  }

  printf("%d\n",pop());

  return 0;
}

void push(int x){
  top++;
  s1[top]=x;
  }
int pop(void){
  top--;
  return s1[top+1];
}

