# frozen_string_literal: true N, X = gets.chomp.split.map(&:to_i) A = gets.chomp.split.map(&:to_i) C = A.group_by(&:itself).map { |k, v| { k => v.size } }.reduce(:merge) B = A.uniq.sort R = (0..(B.size - 1)).map do |i| s = X - B[i] j = B[i..(N - 1)].bsearch_index { |x| x >= s } if j.nil? || B[i + j] != s 0 elsif j.zero? C[s] else C[s] * 2 end end RESULT = R.sum puts RESULT