#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int top,A[200];

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

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

int main(){
  char a[100];
  int x,y;
  
  while( scanf("%s",a)==EOF){
    if(a[0]=='+'){
      x = pop();
      y = pop();
        push(x+y); 
    }

  else if(a[0]=='-'){
      x = pop();
      y = pop();
     push(x-y);
    }

   else if(a[0]=='*'){
      x = pop();
      y = pop();
      push(x*y);
    }

    else{
      push(atoi(a));
    }
  }

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

  return 0;
  
}

