#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
  int num[100];
}Record;

Record push(int);
int size = 0;

int main () {
  char c[100];
  Record data;
  int i, j = 0, sum = 0, x = 1;
  
  while(scanf("%s",c) != EOF) {
    sum = 0;
    x = 1;
    
    if(c[0] == '+') {
      for(i = size - 2 ; i < size ; i++) sum+=data.num[i];
      for(j = i - 2 ; j < i ; j++) size--;
      data = push(sum);
    }
    
    else if(c[0] == '-') {
      i = size - 1;
      sum = data.num[size-2] - data.num[size-1];
      for(j = i - 2 ; j < i ; j++) size--;
      data = push(sum);
    }
    
    else if(c[0] == '*') {
      for(i = size - 2 ; i < size ; i++) x*=data.num[i];
      for(j = i - 2 ; j < i ; j++) size--;
      data = push(x);
    }
    else data = push(atoi(c));     
  }
  printf("%d\n",data.num[0]);
  return 0;
}

Record push(int n) {
  Record data;
  data.num[size] = n;
  size++;

  return data;
}

