N, X = gets.split(" ").map{|s| s.to_i} a = [] N.times { a << gets.to_i } a.sort! cnt = 0 i = 0 while a and a.length > 0 do y = a[0] ycnt = a.bsearch_index{|i| i > y} ycnt = a.length if not ycnt z = y ^ X a = a[ycnt..-1] if z == y then cnt += ycnt * (ycnt - 1) / 2 next end zmin = a.bsearch_index{|i| i >= z} next if not zmin zmax = a.bsearch_index{|i| i > z} zmax = a.length if not zmax zcnt = zmax - zmin cnt += ycnt * zcnt break if zmax == a.length a = a[0, zmin] + a[zmax..-1] end