#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 101

int top=0;
int Stack[MAX];

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

int isfull(){
  if(top >= MAX-1)return 1;
  else return 0;
}

int pop(){
  if(isempty()){
    return NULL;
  }else{
    top--;
    return Stack[top+1];
  }
}

void push(int a){
  if(isfull()){
    return;
  }else{
    top++;
    Stack[top] = a;
  }
}



int main(){
  int top=0,a,b;
  char s[MAX];

  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}
