eval'N,K,*A='+`dd`.split*?, [0,*A.sort,2**N-r=1].each_cons(2){|x,y|r*=x&y