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