<>; @d=sort{$b-$a}glob<>; ($x,$y)=glob<>; if($x==0&&$y==0){ print 0; exit; } $z=abs($x)+abs($y); if(grep$z==$_,@d){ print 1; exit; } ($d0)=@d0=grep{$_%2==0}@d; ($d1)=@d1=grep{$_%2==1}@d; if( $z%2 ) { if( grep{$z>=abs($d1-$_) && $z<=$d1+$_}@d0 ) { print 2; exit; } if( grep{$z>=abs($d0-$_) && $z<=$d0+$_}@d1 ) { print 2; exit; } } else { if( $z<=$d0*2 || $z<=$d1*2 ) { print 2; exit; } } print -1;