($N,$K)=glob<>; $h{$N|$_}=0for 0..511; for$x(keys%h){ for$y(keys%h){ if($x<=$y&&($x&$y)==$N&&$y-$x<=$K){ ++$% } } } print$N==0&&$K!=0?INF:$%