#include<stdio.h>
#include<stdlib.h>
int main(){
  int a,b,c[100],top=0,i=0;
  char s[100],m;
  while( scanf("%s",s) != EOF){
    if ( s[i] == '+' ){
      top = top - 1;
      a = c[top+1];
      top = top - 1;
      b = c[top+1];
      top++;
      c[top] = a + b;
    } else if ( s[i] == '-' ){
      top = top - 1;
      a = c[top+1];
      top = top - 1;
      b = c[top+1];
      top++;
      c[top] = b - a;
    } else if ( s[i] == '*' ){
      top = top - 1;
      a = c[top+1];
      top = top - 1;
      b = c[top+1];
      top++;
      c[top] = a * b;
    } else {
      a = atoi(s);
      top++;
      c[top] = a;
    }
  }
  printf("%d\n", c[top]);
  return 0;
}
