<>;$y=$b?$c+$_-($c=$b)*2?2:$y+1:1,$b=$_,$\+=$-=$y-$\for glob<>;print