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

int pop();
void push();

int main() {
  int x,y,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();
      push(x - y);
    }
    else if(p[0] == '*') {
      x = pop();
      y = pop();
      push(x * y);
    }
    else {
      push(atoi(p));
    }
  }
  printf("%d\n",pop());
  return 0;
}

int top,p[1000];

int pop() {

  top--;
  return p[top+1];
}

void push(int x) {

  p[++top] = x;
}
  
	      

