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

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

int top, S[1000];

int main(){
  int x=0, save1, save2;
  char s[100];



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

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

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

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

    }
  }

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

  return 0;
}


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

int  pop(){
  int n;
  top--;
  n = S[top+1];
  return n;
}

int isFull(void){
  if(top == 99){
    return 1;
  }else{
    return 0;
  }
}

