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

int i=0,num[100];

int pop(){

  i--;
  return num[i];

}

void push(int x){
  num[i] = x;
  i++;

}

int main(){
  int x,ans1,ans2;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      ans1 = pop();
      ans2 = pop();
      push(ans1 + ans2);
    }
    else if ( s[0] == '-' ){

      ans1 = pop();
      ans2 = pop();
      push(ans2 - ans1);
    }
    else if ( s[0] == '*' ){
      ans1 = pop();
      ans2 = pop();
      push(ans1 * ans2);
      
    }
    else {
      x = atoi(s);

      push(x);
      
    }
  }
  
  printf("%d\n",num[i-1]);
  return 0;
}