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

void push(double);
int pop(void);
int y=0;
double b[100];

int main(){
  char a[100];
  double c;
  char x=0;
  while((scanf("%s",a)) != EOF) {
    if(a[0]=='+')push(pop() + pop());
    else if(a[0]=='-'){
      c = pop();
      push(pop() - c);
    }
    else if(a[0]=='*')push(pop() * pop());
    else push(atoi(a));
  }
  printf("%d\n",pop());
  return 0;
}

void push(double f)
{
  if (y < 100)b[y++] = f;
}

int pop(void){
  if (y > 0)
    return b[--y];
  else {
    return 0;
  }
}





