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

void push(char n){
  S[++top] = n;
}

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

int main(){
  int result;
  char s[198];

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




