n, x = gets.split.map(&:to_i) a = gets.split.map(&:to_i) table = a.group_by(&:itself).map { |k,v| [k,v.size] }.to_h count = 0 hx = table[x.fdiv(2)] if hx if hx == 1 count += 1 else count += hx**2 - hx end end table.keys.each do |k| if hx && hx == k next end count += table[k] * (table[x - k] || 0) end puts count