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


int Q[1000];
int top=0;

void push(int);

int pop();


int main(){
  int s1,s2;
  char s[100];
  while( scanf(" %s", s) != EOF ){
    if(s[0]=='+'){
      s1=pop();
      s2=pop();
      push(s1+s2);
    }else if(s[0]=='-'){
      s2=pop();
      s1=pop();
      push(s1-s2);
    }else if(s[0]=='*'){
      s1=pop();
      s2=pop();
      push(s1*s2);
    }else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}

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

int pop(){
  top--;
  return Q[top+1];
}