<>=~$";map{$s+=$a[@a]=$_;$s-=$c=shift@a,$$c=0while$s>$'|$$_;$z[@a]=$$_=1}<>;print$#z