ior = io.read local n, x = ior("*n", "*n") local a = {} for i = 1, n do a[i] = ior("*n") end table.sort(a) local left, right = 1, n local cnt = 0 while(left <= right) do while(left <= right and a[left] + a[right] < x) do left = left + 1 end if(right < left) then break elseif(left == right and a[left] + a[right] == x) then cnt = cnt + 1 break else if(a[left] + a[right] == x) then if(a[left] == a[right]) then cnt = cnt + (right - left + 1) * (right - left + 1) break else local lcnt, rcnt = 1, 1 for tleft = left + 1, right - 1 do if(a[left] == a[tleft]) then lcnt = lcnt + 1 else break end end for tright = right - 1, left + 1 do if(a[right] == a[tright]) then rcnt = rcnt + 1 else break end end cnt = cnt + lcnt * rcnt * 2 right = right - rcnt end else right = right - 1 end end end print(cnt)