#include <stdio.h>
#include <stdlib.h>
#define N 200

main(){
  char c[N];
  int a[N], top = 0, x, y;

  while(scanf("%s", c) != EOF){
    if(c[0] == '+'){
      top = top - 1;
      x = a[top+1];
      top = top - 1;
      y = a[top+1];
      top++;
      a[top] = x + y;
    }
    else if(c[0] == '-'){
      top = top - 1;
      x = a[top+1];
      top = top - 1;
      y = a[top+1];
      top++;
      a[top] = y - x;
    }
    else if(c[0] == '*'){
      top = top - 1;
      x = a[top+1];
      top = top - 1;
      y = a[top+1];
      top++;
      a[top] = x * y;
    }
    else{
      x = atoi(c); 
      top++;
      a[top] = x;
    }
  }
  printf("%d\n", a[top]);
  return 0;
}