#include<stdio.h>
int main(void){
  char a[200];
  int len=0;

  while((scanf(" %c",&a[len]))!=EOF ){
    len++;
    if(a[len-1]=='+' || a[len-1]=='-' || a[len-1]=='*'){
      if(a[len-1]=='+') a[len-3]=a[len-3]+a[len-2];
      else if(a[len-1]=='-') a[len-3]=a[len-3]-a[len-2];
      else a[len-3]=a[len-3]*a[len-2];
      len-=2;
    }
    else a[len-1]-='0';
  }
  printf("%d\n",a[0]);
  return 0;
}