#include<stdio.h>
#define N 1000

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

int top=0,OK[N];

void push(int a){
  top++;
  OK[top] = a;
}

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

int main(){

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