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 if table[x.fdiv(2)] count += table[x.fdiv(2)]**2 end table.keys.each do |k| if x - k < 0 next end count = table[k] * (table[x - k] || 0) end puts count