<>;$/=$";$a[@a&&1+$|--]+=$_ for<>;print$#a=$a[2]?2:$a[1]?1:0," @a"