($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<$K?INF:$%