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

#define MAXOP 100

char get(void);
int pop(void);
void push(int);

int s[MAXOP];
int i = 0;

int main(){
  char type[1];
  int op2;

  while(1) {
    type[0] = get();

    if('0' <= type[0] && type[0] <= '9') push(atoi(type));
    if(type[0] == '\n') break;

    switch (type[0]){
    case '+':
      push(pop() + pop());
      break;

    case '*':
      push(pop() * pop());
      break;

    case '-':
      op2 = pop();
      push(pop() - op2);
      break;
    }
  }

  printf("%d\n",pop());

  return 0;
}

char get(void){
  char c;

  while(1){
    scanf("%c",&c);
    if(c != ' ') break;
  }

  return c;  
}

int pop(void){
  int a;

  if(i > 0){
    a = s[i];
    i--;
    return a;
  }
}

void push(int a){
  s[i] = a;
  i++;
}