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

int main(){
  int a;
  char A[N];
  signed long long B[N];
  int  b = 0;

  while( scanf("%s", A) != EOF ){
    if ( A[0] == '+' ){
      b--;
      B[b - 1] += B[b];
    } else if ( A[0] == '-' ){
      b--;
      B[b - 1] -= B[b];
    } else if ( A[0] == '*' ){
      b--;
      B[b - 1] *= B[b];
    } else {
      a = atoi(A);
      B[b] = a;
      b++;
    }
  }

  printf("%lld\n", B[0]);

  return 0;
}
