#include <stdio.h>
#define N 10000
int s[N];

int p;

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

int pp() {
  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=pp();
      int y=pp();
      if(c[0]=='*') rr(x*y);
      else if(c[0]=='-') rr(y-x);
      else if(c[0]=='+')rr(x+y);
    }
    else {
      int x=0,k=0;
      while(c[k]>='0' && c[k]<='9')
      {
	        x*=10;
	        x+=c[k]-'0';
	        k++;
      }

      rr(x);
    }
  }

  printf("%d\n",pp());


  return 0;
}

