<>;$_=<>;s/\d+/$d|=$c[$&]++if$&-$'/ger;print$d?$d>1|$&-$_?-1:1:0