#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top = 0;
int S[200];

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

int isFull(){
  if(top >= 197) return 1;
  else return 0;
}

void push(char n){
  if (isFull() == 1) fprintf(stderr,"stac is full(over fllow)\n"); exit(1);
  S[++top] = n;
}

int pop(){
  int x;
  if (isEmpty()== 1) fprintf(stderr,"stac is empty(under fllow)\n"); exit(1);
  top--;
  x = S[top+1] - '0';
  return x;
}

int main(){
  int a;
  int b;
  char s[198];

  while(scanf(" %s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(s[0] == '-'){
      a = pop();
      b = pop();
      push(a - b);
    }
    else if(s[0] == '*'){
      a = pop();
      b = 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;
}




