#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int a();
void b();
int c[1000],top=0;
 
int main() {
 
  int d,e;
  char s[100];
 
  while(scanf("%s",s)!=EOF) {
    if(s[0]=='+') {
      d = a();
      e = a();
      b(d+e);
    }
    else if(s[0]=='*') {
      d = a();
      e = a();
      b(d*e);
    }
    else if(s[0]=='-') {
      d = a();
      e = a();
      b(e-d);
    }
    else b(atoi(s));
  }
  printf("%d\n",a());
 
  return 0;
}
 
int a() {
  top--;
  return c[top+1];
}
 
void b(int x) {
  c[++top] = x;
}