#include <stdio.h>
#include <stdlib.h>
#define MAX 1000
void push(int);
int pop(void);
int top;
int S[MAX];
int main(){
  char str[199];
  int i,x,y;
  top = 0;
  while( scanf("%s",str) != EOF ){
    switch(str[0]){
    case '+':
      x = pop();
      y = pop();
      push(x + y);
      break;
    case '-':
      y = pop();
      x = pop();
      push(x - y);
      break;
    case '*':
      x = pop();
      y = pop();
      push(x * y);
      break;
    default:
      push(atoi(str));
      break;
    }
  }
    printf("%d\n",pop());
    return 0;
}
void push(int x){
  S[++top] = x;
}
int pop(){
  top--;
  return S[top+1];
}

