<>;s/\d+/$d[$c[$b=$&]++]=0if$b-$&/gefor<>x2;print+(1,1,2)[$#d]-1