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

int main(){
  int x,y,top=0;
  char s[100];
  int a[10000];
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      top--;
      x=a[top];
      top--;
      y=a[top];
      a[top]=x+y;
      top++;
    }
    else if ( s[0] == '-' ){
      top--;
      x=a[top];
      top--;
      y=a[top];
      a[top]=y-x;
      top++;
    }
    else if ( s[0] == '*' ){
      top--;
      x=a[top];
      top--;
      y=a[top];
      a[top]=x*y;
      top++;
    }
    else {
      x = atoi(s);
      a[top]=x;
      top++;
    }
  }

  printf("%d\n",a[top-1]);

  return 0;
}

