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

#define TRUE 1
#define FALSE 0

typedef struct{
  int stk[1000];
  int top;
}Stack;

Stack S;

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

int main(){
  int x;
  int a, b;
  char s[100];

  S.top = 0;

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

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

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

  return 0;
}

int isEmpty(){
  if(S.top == 0)
    return TRUE;

  else
    return FALSE;
}

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

int pop(){
  if(isEmpty()){
    fprintf(stderr,"underflow!!");
    exit(8);
  }

  else
    S.top--;

  return S.stk[S.top + 1];
}

