#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, s[100000];
int pop() {
  top--;
  return s[top+1];
}

void push(int t) {
  s[++top] = t;
}

int main() {
  int x, y, tmp;
  top = 0;
  char p[100];

  while(scanf("%s", p) != EOF){
    if (p[0]=='+'){
      x = pop();
      y = pop();
      push(x+y);
    } 

    else if(p[0]=='-'){
      y = pop();
      x = pop();
      tmp = x-y;
      push(x-y);
    }
 
    else if(p[0]=='*'){
      x = pop();
      y = pop();
      push(x*y);
    }
 
    else{
      push(atoi(p));
    }
  }

  printf("%d\n", pop());
  return 0;
}

