#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100

int main(){
  int x[N];
  char s[N];
  int top=0;

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