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

int top;
int Stack[102];

int pop();
void push(int x);

int main(){
  int x, y;
  top = 0;
  char s[100];

  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      x = pop();
      y = pop();
      push(x+y);
    }else if(s[0] == '-'){
      x = pop();
      y = pop();
      push(y-x);
    }else if(s[0] == '*'){
      x = pop();
      y = pop();
      push(x*y);
    }else{
      push(atoi(s));
    }
  }

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

  return 0;
}

int pop(){
  top--;
  return Stack[top+1];
}

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

