#include <stdio.h>

int s[1000];
int p;

void push(int x) {
  s[p]=x;
  p++;
}

int pop() {
  p--;
  return s[p];
}

int main() {
  p=0;
  char c[10];
  while(scanf("%s",c)==1) {
    if(c[0]=='+' || c[0]=='-' || c[0]=='*') {
      int x=pop();
      int y=pop();
      if(c[0]=='+') push(x+y);
      else if(c[0]=='-') push(y-x);
      else push(x*y);
    } else {
      int x=0,k=0;
      while(c[k]>='0' && c[k]<='9') {
	x*=10;
	x+=c[k]-'0';
	k++;
      }
      push(x);
    }
  }
  printf("%d\n",pop());
  return 0;
}
