#include<stdio.h>
#include<stdlib.h>
#define N 200
void push(int);
int pop(void);
int c[N];
int num=0;

int main(){
  char s[N];
  int op;
  while(scanf("%s",s)!=EOF){
  switch (s[0]) {
    case '+':
    push(pop()+pop());
    break;
    case '-':
    op=pop();
    push(pop()-op);
    break;
    case '*':
    push(pop()*pop());
    break;
    default:
    push(atoi(s));
    break;
  }
}
printf("%d\n",pop());
  return 0;
}
void push(int x) {
  num++;
  c[num]=x;
}
int pop(void){
  num--;
  return c[num+1];
}

