sub min{$_[0]<$_[1]?$_[0]:$_[1]} sub max{$_[0]>$_[1]?$_[0]:$_[1]} ($d,$i,$h,$j)=<>; exit!print $i<$h&&$j<$h||$i>$h&&$j>$h?0:-1 if $d==0; $n=min($i,$j)==0?1e11:max(0,int(($h-min($i,$j)+$d)/$d)); $o=$h==0?1e11:max(0,int(($i-$h+$d)/$d)); $p=$h==0?1e11:max(0,int(($j-$h+$d)/$d)); $n=min($n,$o+$p); $n=-1 if $n>=1e11; print$n