#include <stdio.h>
#include <stdlib.h>
#define M 100

int main()
{
  int i = 0,x[M];
  char stack[M];
  int state;
  while (1) {
    if (scanf("%s", &stack[i]) == EOF)break;
    if(stack[i]=='+'){
      x[i-2] = x[i-2]+x[i-1];
      i-=2;
    }
    else if (stack[i] == '-') {
      x[i-2]=x[i-2]-x[i-1];
      i-=2;
    }
    else if (stack[i] == '*') {
      x[i-2]=x[i-2]*x[i-1];
      i-=2;
    }
		
    else {
      x[i] = atoi(&stack[i]);
    }
    i++;
  }
  printf("%d\n",x[0]);
  return 0;
}

