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

int top,s[100];

void push(int data){
  s[++top] = data;
}

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

int main(){
  int i,j;
  top = 0;
  char mozi[100];
  while( scanf("%s",mozi)!= EOF){
    if(mozi[0] == '+'){
      i = pop();
      j = pop();
      push(i + j);
    }else if(mozi[0] == '-'){
      j = pop();
      i = pop();
      push(i-j);
    }else if(mozi[0] == '*'){
      i = pop();
      j = pop();
      push(i*j);
    }else{
      push(atoi(mozi));
    }
  }

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

  return 0;
}
