#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void push(int);
int top =0;
int K[100];


int main(){
  int i = 0,j,x;
  char s[100],num;
   
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      K[top-1] = K[top-1] + K[top];
      K[top]= 0;
      top--;

    } else if ( s[0] == '-' ){
      K[top-1] = K[top-1] - K[top];
      K[top]= 0;
      top--;

    } else if ( s[0] == '*' ){
      K[top-1] = K[top-1] * K[top];
      K[top]= 0;
      top--;

    } else {
      x = atoi(s);
      push(x);
  }
  }
  printf("%d\n",K[top]);

  return 0;
}

void push(int x){
  top++;
  K[top] = x;
  
}