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

int stack[100],top = 0;

int isempty();
int isfull();
void push(int);
int pop();

int main(){
  int x,y;
  char s[8];

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

    else if(s[0] == '-'){
      x = pop();
      y = pop();
      x = y - x;
      push(x);
    }

    else if(s[0] == '*'){
      x = pop() * pop();
      push(x);
    }

    else{
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());
  
  return 0;
}

int isempty(){
  if(top <= 0) return 0;
  return 1;
}

int isfull(){
  if(top == 100) return 0;
  return 1;
}

void push(int x){
  if(isfull() == 0) exit(1);
  stack[top++] = x;
}

int pop(){
  if(isempty() == 0) exit(2);
  return stack[--top];
}

